0.0.3 • Published 6 years ago
recaptcha-react v0.0.3
recaptcha-react
A React component for rendering a reCAPTCHA captcha ✅
Live Playground
To run the demo on your own computer:
- Clone this repository
$ npm install
- Set your reCAPTCHA keys in
stories/storybook-config.js
$ npm run storybook
- Visit http://localhost:6006/
Getting Started
Install dependencies
Ensure packages are installed with correct version numbers by running:
(
export PKG=recaptcha-react;
npm info "$PKG" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g; s/ *//g' | xargs npm install --save "$PKG"
)
Which produces and runs a command like:
npm install --save recaptcha-react react@>=#.## react-dom@>=#.## ...
Usage
recaptcha-react
exports a single component — Recaptcha
. Simply import it and
render wherever you need a captcha. See the props table below for how to configure
the captcha to your needs.
import Recaptcha from 'recaptcha-react';
export default function MyCaptcha() {
return (
<Recaptcha siteKey="xxx" onChange={token => alert(token)} />
);
}
Props
name | type | isRequired | default value |
---|---|---|---|
siteKey | string | true | |
onChange | function | true | |
autoExecuteWhenInvisible | function | true | |
badge | 'bottomleft' | 'bottomright' | 'inline' | 'inline' | |
component | string | function | 'div' | |
invisible | boolean | false | |
onError | function | ||
onExpired | function | ||
size | 'compact' | 'normal' | 'normal' | |
tabIndex | number | 0 | |
theme | 'dark' | 'light' | 'light' | |
type | 'audio' | 'image' | 'image' |