react-grecaptcha
React.js Google reCAPTCHA v2 integration component.
Feature
- Isomorphic support. (Only render on client side.)
- Lazy load scripts for routing.
- Automatically render the reCAPTCHA widget.
- I18n support. https://developers.google.com/recaptcha/docs/language
- Simple to use.
Demo
- Storybook: react-grecaptcha.netlify.com
- Webpackbin: webpackbin.com/bins/-KjCPM_MB-WIp-vxaBCy
Installation
$ yarn add react-grecaptcha
Usage
; const verifyCallback = console;const expiredCallback = {...}; <Recaptcha sitekey=RECAPTCHA_SITE_KEY callback=verifyCallback expiredCallback=expiredCallback locale="zh-TW" className="customClassName" // Other props will be passed into the component. data-theme="dark"/>
API
- To reset the recaptcha:
windowgrecaptcha; // You can use other functions the same way.windowgrecaptchaexecutewindowgrecaptchagetResponsewindowgrecaptcharender...
Development
Requirements
- node >= 9.4.0
- yarn >= 1.3.2
$ yarn install --pure-lockfile
$ yarn start
Test
$ yarn run format
$ yarn run eslint
$ yarn run test:watch
$ yarn run build
$ yarn run build-storybook
CONTRIBUTING
- ⇄ Pull requests and ★ Stars are always welcome.
- For bugs and feature requests, please create an issue.
- Pull requests must be accompanied by passing automated tests (
$ yarn test
).