recaptcha-react-hook
v1.0.8
Published
React hook for google-recaptcha v3
Downloads
4
Maintainers
Readme
react-recaptcha-hook
React hook for google-recaptcha v3
Install
// with npm
npm install react-recaptcha-hook
// with yarn
yarn add react-recaptcha-hook
How to use
import React, { useEffect } from 'react';
import useRecaptcha, { Badge } from 'react-recaptcha-hook';
const RecaptchaComponent = ({ action, sitekey, onToken }) => {
const execute = useRecaptcha({ sitekey, hideDefaultBadge: true });
useEffect(() => {
const getToken = async () => {
const token = await execute(action);
onToken(token);
};
getToken();
}, []);
return <Badge />;
};
export default RecaptchaComponent;