Verifies Google reCAPTCHA v3 tokens before selected collection operations run. You register the plugin with your secret key, then list protected operations and actions in each collection's custom config. Clients send the token in the x-recaptcha-v3 header. Requires Payload 3.
This library implements a collection protection in Payload CMS using Google reCAPTCHA v3.
Installation
npm i payload-recaptcha-v337
Stars
4
Forks
2
Open Issues
1 years ago
Last Updated
183
Weekly Downloads
v3.1.1
npm Version
353.5 KB
Unpacked Size
1
Dependencies
37+2 since Sep 7
| Date | Stars |
|---|---|
| Dec 6, 2026 | 37 |
| Dec 5, 2026 | 37 |
| Dec 4, 2026 | 37 |
| Dec 3, 2026 | 37 |
| Dec 2, 2026 | 37 |
| Dec 1, 2026 | 37 |
| Nov 30, 2026 | 37 |
| Nov 29, 2026 | 37 |
| Nov 28, 2026 | 37 |
| Nov 27, 2026 | 37 |
| Nov 26, 2026 | 37 |
| Nov 25, 2026 | 37 |
| Nov 24, 2026 | 37 |
| Nov 23, 2026 | 37 |
| Nov 22, 2026 | 37 |
| Nov 21, 2026 | 37 |
| Nov 20, 2026 | 37 |
| Nov 19, 2026 | 37 |
| Nov 18, 2026 | 37 |
| Nov 17, 2026 | 37 |
| Nov 16, 2026 | 37 |
| Nov 15, 2026 | 37 |
| Nov 14, 2026 | 37 |
| Nov 13, 2026 | 37 |
| Nov 12, 2026 | 37 |
| Nov 11, 2026 | 37 |
| Nov 10, 2026 | 36 |
| Nov 9, 2026 | 36 |
| Nov 8, 2026 | 36 |
| Nov 7, 2026 | 36 |
| Nov 6, 2026 | 36 |
| Nov 5, 2026 | 36 |
| Nov 4, 2026 | 36 |
| Nov 3, 2026 | 35 |
| Nov 2, 2026 | 35 |
| Nov 1, 2026 | 35 |
| Oct 31, 2026 | 35 |
| Oct 30, 2026 | 35 |
| Oct 29, 2026 | 35 |
| Oct 28, 2026 | 35 |
| Oct 27, 2026 | 35 |
| Oct 26, 2026 | 35 |
| Oct 25, 2026 | 35 |
| Oct 24, 2026 | 35 |
| Oct 23, 2026 | 35 |
| Oct 22, 2026 | 35 |
| Oct 21, 2026 | 35 |
| Oct 20, 2026 | 35 |
| Oct 19, 2026 | 35 |
| Oct 18, 2026 | 35 |
| Oct 17, 2026 | 35 |
| Oct 16, 2026 | 35 |
| Oct 15, 2026 | 35 |
| Oct 14, 2026 | 35 |
| Oct 13, 2026 | 35 |
| Oct 12, 2026 | 35 |
| Oct 11, 2026 | 35 |
| Oct 10, 2026 | 35 |
| Oct 9, 2026 | 35 |
| Oct 8, 2026 | 35 |
| Oct 7, 2026 | 35 |
| Oct 6, 2026 | 35 |
| Oct 5, 2026 | 35 |
| Oct 4, 2026 | 35 |
| Oct 3, 2026 | 35 |
| Oct 2, 2026 | 35 |
| Oct 1, 2026 | 35 |
| Sep 30, 2026 | 35 |
| Sep 29, 2026 | 35 |
| Sep 28, 2026 | 35 |
| Sep 27, 2026 | 35 |
| Sep 26, 2026 | 35 |
| Sep 25, 2026 | 35 |
| Sep 24, 2026 | 35 |
| Sep 23, 2026 | 35 |
| Sep 22, 2026 | 35 |
| Sep 21, 2026 | 35 |
| Sep 20, 2026 | 35 |
| Sep 19, 2026 | 35 |
| Sep 18, 2026 | 35 |
| Sep 17, 2026 | 35 |
| Sep 16, 2026 | 35 |
| Sep 15, 2026 | 35 |
| Sep 14, 2026 | 35 |
| Sep 13, 2026 | 35 |
| Sep 12, 2026 | 35 |
| Sep 11, 2026 | 35 |
| Sep 10, 2026 | 35 |
| Sep 9, 2026 | 35 |
| Sep 8, 2026 | 35 |
| Sep 7, 2026 | 35 |
200+121 since Sep 7
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 200 |
| Dec 5, 2026 | 233 |
| Dec 4, 2026 | 213 |
| Dec 3, 2026 | 230 |
| Dec 2, 2026 | 243 |
| Dec 1, 2026 | 250 |
| Nov 30, 2026 | 252 |
| Nov 29, 2026 | 263 |
| Nov 28, 2026 | 250 |
| Nov 27, 2026 | 254 |
| Nov 26, 2026 | 276 |
| Nov 25, 2026 | 270 |
| Nov 24, 2026 | 271 |
| Nov 23, 2026 | 270 |
| Nov 22, 2026 | 282 |
| Nov 21, 2026 | 312 |
| Nov 20, 2026 | 340 |
| Nov 19, 2026 | 324 |
| Nov 18, 2026 | 335 |
| Nov 17, 2026 | 344 |
| Nov 16, 2026 | 333 |
| Nov 15, 2026 | 301 |
| Nov 14, 2026 | 253 |
| Nov 13, 2026 | 202 |
| Nov 12, 2026 | 188 |
| Nov 11, 2026 | 166 |
| Nov 10, 2026 | 146 |
| Nov 9, 2026 | 143 |
| Nov 8, 2026 | 153 |
| Nov 7, 2026 | 157 |
| Nov 6, 2026 | 160 |
| Nov 5, 2026 | 161 |
| Nov 4, 2026 | 172 |
| Nov 3, 2026 | 180 |
| Nov 2, 2026 | 182 |
| Nov 1, 2026 | 160 |
| Oct 31, 2026 | 152 |
| Oct 30, 2026 | 167 |
| Oct 29, 2026 | 133 |
| Oct 28, 2026 | 94 |
| Oct 27, 2026 | 76 |
| Oct 26, 2026 | 93 |
| Oct 25, 2026 | 100 |
| Oct 24, 2026 | 140 |
| Oct 23, 2026 | 103 |
| Oct 22, 2026 | 135 |
| Oct 21, 2026 | 190 |
| Oct 20, 2026 | 188 |
| Oct 19, 2026 | 183 |
| Oct 18, 2026 | 191 |
| Oct 17, 2026 | 171 |
| Oct 16, 2026 | 220 |
| Oct 15, 2026 | 220 |
| Oct 14, 2026 | 241 |
| Oct 13, 2026 | 245 |
| Oct 12, 2026 | 228 |
| Oct 11, 2026 | 211 |
| Oct 10, 2026 | 211 |
| Oct 9, 2026 | 173 |
| Oct 8, 2026 | 168 |
| Oct 7, 2026 | 97 |
| Oct 6, 2026 | 95 |
| Oct 5, 2026 | 90 |
| Oct 4, 2026 | 92 |
| Oct 3, 2026 | 95 |
| Oct 2, 2026 | 96 |
| Oct 1, 2026 | 98 |
| Sep 30, 2026 | 108 |
| Sep 29, 2026 | 136 |
| Sep 28, 2026 | 139 |
| Sep 27, 2026 | 155 |
| Sep 26, 2026 | 176 |
| Sep 25, 2026 | 192 |
| Sep 24, 2026 | 198 |
| Sep 23, 2026 | 206 |
| Sep 22, 2026 | 190 |
| Sep 21, 2026 | 188 |
| Sep 20, 2026 | 188 |
| Sep 19, 2026 | 160 |
| Sep 18, 2026 | 151 |
| Sep 17, 2026 | 135 |
| Sep 16, 2026 | 124 |
| Sep 15, 2026 | 109 |
| Sep 14, 2026 | 113 |
| Sep 13, 2026 | 108 |
| Sep 12, 2026 | 91 |
| Sep 11, 2026 | 86 |
| Sep 10, 2026 | 87 |
| Sep 9, 2026 | 84 |
| Sep 8, 2026 | 83 |
| Sep 7, 2026 | 79 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/679237214-root)<a href="https://payloaddirectory.dev/plugins/679237214-root"><img src="https://payloaddirectory.dev/badge/679237214-root.svg" alt="Payload Directory"></a>README
Payload reCAPTCHA v3 is a plugin for Payload used to protect collection operations with Google reCAPTCHA v3.
Please install the plugin version according to the Payload version. The major version of the plugin must match the major version of the Payload.
yarn add payload-recaptcha-v3
npm i payload-recaptcha-v3
pnpm add payload-recaptcha-v3
In the plugins property of Payload config, call the plugin with the following options:
import { buildConfig } from 'payload';
import reCAPTCHAv3 from 'payload-recaptcha-v3';
export default buildConfig({
// ... rest of your config
plugins: [
reCAPTCHAv3({
secret: process.env.GOOGLE_RECAPTCHA_SECRET!,
}),
],
});
secret: string
Required. Your Google reCAPTCHA v3 secret key.errorHandler: reCAPTCHAErrorHandler
Optional. See more detailsskip: reCAPTCHASkip
Optional. See more detailsscoreThreshold: number
Optional. A value between 0 and 1 (default is 0.7). The received score from Google reCAPTCHA must be greater or equal than threshold.To protect a collection's operation, you have to add in the Collection Config the property recaptcha into the custom.
The recaptcha property has to be an array of strings containing the operation name according to Available Collection operations.
import type { CollectionConfig } from 'payload';
export const Orders: CollectionConfig = {
slug: 'orders',
fields: [],
// ... rest of your config
custom: {
recaptcha: [
{
name: 'create',
action: 'submit',
},
{
name: 'update',
action: 'modify',
},
],
},
};
export default Orders;
Then, when you make an HTTP Request to the Payload API, include the header x-recaptcha-v3 with the token received from Google:
<script>
function onClick(e) {
e.preventDefault();
grecaptcha.ready(function() {
grecaptcha.execute('reCAPTCHA_site_key', {action: 'submit'}).then(function(token) {
fetch('/api/orders', {
method: 'POST',
headers: {
'x-recaptcha-v3': token
},
body: JSON.stringify({...})
})
});
});
}
</script>
Optionally, you can set a errorHandler or skip as described in Plugin Options in a specific operation.
import type { CollectionConfig } from 'payload';
export const Orders: CollectionConfig = {
slug: 'orders',
fields: [],
// ... rest of your config
custom: {
recaptcha: [
{
name: 'create',
action: 'submit',
errorHandler: (args) => {
// ...
},
},
{
name: 'update',
action: 'modify',
skip: (args) => {
// ....
},
},
{
name: 'delete',
action: 'delete',
scoreThreshold: 0.9,
}
],
},
};
export default Orders;
This plugin uses Playwright for end-to-end testing with Google reCAPTCHA directly. However, there are some steps to test the plugin.
DATABASE_URI, RECAPTCHA_SECRET and NEXT_PUBLIC_RECAPTCHA_SITE_KEY environment variables.pnpm build and then pnpm dev:build.pnpm test.A callback function that when returns true, it will skip the Google reCAPTCHA verification (for example, when the user is an admin).
The arguments of function are the same of Before Operation Hook.
export type reCAPTCHASkip = (
args: Parameters<CollectionBeforeOperationHook>[0],
) => boolean;
A callback function that is called when:
When the errorHandler options property is not set, it will throw a Forbidden error by default.
export type reCAPTCHAErrorHandler = (args: {
hookArgs: Parameters<CollectionBeforeOperationHook>[0];
response?: reCAPTCHAResponse;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
error?: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
}) => any;
The response received from Google when verifying the token.
Properties
| Name | Description |
|---|---|
| success: boolean | whether this request was a valid reCAPTCHA token for your site |
| score: number | the score for this request (0.0 - 1.0) |
| action: string | the action name for this request (important to verify) |
| challenge_ts: number | timestamp of the challenge load (ISO format yyyy-MM-dd'T'HH:mm:ssZZ) |
| hostname: string | the hostname of the site where the reCAPTCHA was solved |
| 'error-codes'?: reCAPTCHAErrorCode[] | optional |
| Error code | Description |
|---|---|
| missing-input-secret | The secret parameter is missing. |
| invalid-input-secret | The secret parameter is invalid or malformed. |
| missing-input-response | The response parameter is missing. |
| invalid-input-response | The response parameter is invalid or malformed. |
| bad-request | The request is invalid or malformed. |
| timeout-or-duplicate | The response is no longer valid: either is too old or has been used previously. |
| invalid-keys | The secret key is incorrect. |
form builder
Let admin editors build and manage forms from within the Payload admin panel
100171.2k/wk46.1kv3 v4
payload forms
Visual drag-and-drop form builder with submissions, email notifications and CSV import/export
3639/wk5v3
payload contact
Contact form with a message inbox, runtime settings and spam protection for Payload 3
222v3
payload plugin contact tiles
Routed contact page with topic autocomplete, quick tiles and one form that emails the topic's group address
74161/wk0v3
payload plugin wizards
Gated step-by-step wizards with admin-edited steps and server-verified, recorded answers
64193/wk0v3
form builder app 1 2025
Next.js and Payload app using the form builder plugin to create forms and accept submissions with file attachments
151/wk7v?