@google-recaptcha/core
v1.0.5
Published
Tool that easily and quickly add Google ReCaptcha for your website or application
Downloads
3,767
Maintainers
Readme
🔑 Core Google ReCaptcha
🔑 tool that easily and quickly add Google ReCaptcha for your website or application
Install
$ npm i @google-recaptcha/core
# or
$ yarn add @google-recaptcha/core
🦉 Philosophy
🔑 Google ReCaptcha this is a library that will allow you to easily and quickly add Google ReCaptcha for your website or application. The main difference from other libraries is that all current versions of Google ReCaptcha are supported here.
Features
- Support all recaptcha versions - support v3, v2-checkbox, v2-invisible
- Enterprise mode - support enterprise
- TypeScript support out of the box - full typed package
- SSR - package work with server side render
Usage
Install 🔑 Core Google ReCaptcha with npm or yarn
$ npm i @google-recaptcha/core
# or
$ yarn add @google-recaptcha/core
V3
Google ReCaptcha v3 returns a score for each request without user friction. The score is based on interactions with your site and enables you to take an appropriate action for your site.
V2 invisible
Google ReCaptcha v2 invisible does not require users to solve any puzzles or enter any codes. Instead, it runs in the background and analyzes user behavior on the web page to determine if they are genuine users or potential bots.
V2 checkbox
When a user interacts with the Google ReCaptcha v2 checkbox, advanced algorithms analyze their behavior to distinguish between humans and bots. If the system suspects suspicious activity, additional challenges may be presented, such as image selections or puzzle-solving tasks.
Enterprise
Google ReCaptcha Enterprise is built on the existing reCAPTCHA API and it uses advanced risk analysis techniques to distinguish between humans and bots.
In order to enable enterprise mode, you need to set the flag isEnterprise
in GoogleReCaptchaProvider
. Also in this mode you can pass specials actions
.
API
generateGoogleReCaptchaScriptSrc
The function generateGoogleReCaptchaScriptSrc
function may be needed for applications with ssr to get a link for the recaptcha script and load it before rendering the UI.
| Parameters | Type | Required | Note |
| -------------- | :---------------------------------------: | ------------ | -------------------------------------------------------------------------------------------- |
| host | recaptcha.net
or google.com
| No | Load script from recaptcha.net
or google.com
|
| isEnterprise | Boolean | Yes | |
| render | String | Yes | siteKey of reCaptcha |
| hl | String | No | Prop to support different languages that is supported by Google Recaptcha |
| badge | inline
or bottomleft
or bottomright
| No | Reposition the reCAPTCHA badge. Depends on type of reCaptcha. If not provide badge is hidden |
generateGoogleReCaptchaHiddenBadgeStyles
The function generateGoogleReCaptchaHiddenBadgeStyles
function returns hidden styles for Google ReCaptcha badge.