npm

Need private packages and team management tools?Check out npm Orgs. »

recaptcha-frontend

1.0.1 • 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.

install

npm i recaptcha-frontend

Downloadsweekly downloads

2

version

1.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability