React Captcha

React Captcha

·

1 min read

React Captcha is a form validation component based on Recaptcha.

Setup

Refer to PrimeReact setup documentation for download and installation steps for your environment.

Import

import { Captcha } from 'primereact/captcha';

Getting Started

Captcha is used with a siteKey and a callback to verify the response.

<Captcha siteKey="YOUR_SITE_KEY" onResponse={showResponse}></Captcha>

Verification

In order to ensure if a response token is valid, verification against recaptcha api needs to be done at backend. Read more at official documentation.

const showResponse = (response) => {
//call to a backend to verify against recaptcha with private key
}

In addition, include the captcha widget resource to your page.

<script src="https://www.google.com/recaptcha/api.js?render=explicit" async defer></script>

Theming

Captcha supports various themes featuring Material, Bootstrap, Fluent as well as your own custom themes via the Designer tool.

Resources

Visit the PrimeReact Captcha showcase for demos and documentation.