recaptcha-frontend

1.0.5 • Public • Published

Google reCAPTCHA v3 - Frontend Integration

npm npm bundle size (minified)

ES module for the Google reCAPTCHA v3 frontend integration.

Install

$ npm install --save recaptcha-frontend

Usage

Pick your favorite:

const { execute, load } = require("recaptcha-frontend");
import execute, { load } from 'recaptcha-frontend';

... then all you need is:

execute('homepage', 'site-key').then((token) => {
    // Send `token` to your backend for verification.
});

execute() will automatically load the reCAPTCHA v3 API and execute your request in a single step. You can also preload the API and call execute() later, without specifying your site key on every call:

load('site-key').then(() => {
    // The API is loaded and ready.
});

// Do other things ...

execute('homepage').then(token => {
    // Send `token` to your backend for verification.
});

API

load(siteKey, [recaptchaNet = false])

Returns: (Promise) The fulfillement handler (then) is called when the API is loaded and ready.

Loads the API.

execute(action, [siteKey], [recaptchaNet = false])

  • action (string) The action to execute.
  • siteKey (string) Your reCAPTCHA site key. If not specified, will use the last site key provided to load() or execute().
  • recaptchaNet (boolean) Whether to use the recaptcha.net alternate URL to load the API.

Returns: (Promise) The fulfillment handler (then) receives a single token parameter that can be used for verification.

Executes an action. Loads the API if needed.

showBadge()

Shows the reCAPTCHA badge.

hideBadge()

Hides the reCAPTCHA badge. This requires the reCAPTCHA branding to be included visibly in the user flow.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.5
    2
    • latest

Version History

Package Sidebar

Install

npm i recaptcha-frontend

Weekly Downloads

8

Version

1.0.5

License

MIT

Unpacked Size

6.57 kB

Total Files

4

Last publish

Collaborators

  • idmadj