hCaptcha Component Library for ReactJS.
hCaptcha is an easy to use replacement for reCAPTCHA that helps monetize your website.
Sign up at hCaptcha to get your sitekey today. You need a sitekey to use this captcha solution.
You can install this library via npm with:
npm install react-hcaptcha --save
<your-cool-form>
<hCaptcha :sitekey="**Your sitekey here**" onVerify={this.onVerifyCaptcha}></hCaptcha>
</your-cool-form>
The two required props are the sitekey and root component. The component will automatically include and load the hCaptcha API library and append it to the root component. This is designed for ease of use with the hCaptcha API!
Props include:
The component emits events related to verification and expiration. Simply catch these events in the parent component: onVerify
, onExpire
, onError
and handle the events as you choose. The captcha will automatically reset on error, but still emits an error.
NOTE: Make sure to reset the hCaptcha state when you submit your form by calling the method .resetCaptcha
on your hCaptcha React Component! Passcodes are one-time use, so if your user submits the same passcode twice then it will be rejected by the server the second time.
Please refer to the demo for examples of basic usage and an invisible hCaptcha.
This repository can be found on npm at @hcaptcha/react-hcaptcha. If any updates are committed to master the npm registry should be updated to reflect these changes. See steps below to update the package on npm:
Maintainer
of @hcaptcha/react-hcaptchanpm publish
from inside the current repositoryAuthor: hCaptcha
Official Website: https://github.com/hCaptcha/react-hcaptcha
#reactjs #javascript