Have ideas to improve npm?Join in the discussion! »

    react-recaptcha-hook
    TypeScript icon, indicating that this package has built-in type declarations

    1.2.2 • Public • Published

    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;

    Server side validation

    License

    MIT

    Install

    npm i react-recaptcha-hook

    DownloadsWeekly Downloads

    1,059

    Version

    1.2.2

    License

    MIT

    Unpacked Size

    12.4 kB

    Total Files

    16

    Last publish

    Collaborators

    • avatar