Integration Google reCaptcha with React hooks.
npm install react-use-recaptcha-v3 --save
1. Get your site key for ReCaptcha V3
2. Implement Back End side
const ControlledGoogleReCaptcha = () => {
const siteKey = '[SET UP YOU SITE KEY HERE!!!]';
const actionName = 'submit'; // you can change actionName here if you need
const { execute } = useReCaptcha(siteKey, actionName);
const submitForm = async () => {
const token = await execute();
// submit you form with token
};
return <form>[ANY FORM HERE]</form>;
};
const GReCaptchaReduxFormField = ({ input: { onChange } }) => {
const siteKey = '[SET UP YOU SITE KEY HERE!!!]';
const actionName = 'submit'; // you can change actionName here if you need
useReCaptcha(siteKey, actionName, onChange);
return null;
};