Captcha is a form validation component based on Recaptcha.
import { Captcha } from 'primereact/captcha';
<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/captcha/captcha.min.js"></script>
Captcha is used with a siteKey and a callback to verify the response.
<Captcha siteKey="YOUR_SITE_KEY" onResponse={showResponse}></Captcha>
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>
Name | Type | Default | Description |
---|---|---|---|
id | string | null | Unique identifier of the element. |
siteKey | string | null | Public sitekey. |
theme | string | light | The color scheme of the widget. |
type | string | image | The type of CAPTCHA to serve. |
size | string | normal | The size of the widget. |
tabIndex | number | 0 | The tabIndex of the widget and challenge. |
language | string | en | Language of the widget. |
Name | Parameters | Description |
---|---|---|
onResponse | event.response: The user response token. | The callback function to be executed when the user submits a successful CAPTCHA response. |
onExpire | - | The callback function to be executed when the recaptcha response expires and the user needs to solve a new CAPTCHA. |
Name | Parameters | Description |
---|---|---|
reset | - | Resets the reCAPTCHA widget. |
getResponse | - | Gets the response for the reCAPTCHA widget. |
This section is under development. After the necessary tests and improvements are made, it will be shared with the users as soon as possible.
Google Recaptcha V2
Built-in component themes created by the PrimeReact Theme Designer.
Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.
Beautifully crafted premium create-react-app application templates by the PrimeTek design team.