Skip to main content

React Google reCAPTCHA V3

Protect your React applications from spam and abuse with Google’s reCAPTCHA V3. Easy-to-use components, hooks, and HOCs for seamless integration.

Quick Start

Get reCAPTCHA V3 working in your React app in just a few steps

1

Install the package

Install react-google-recaptcha-v3 via npm, yarn, or pnpm:
npm install react-google-recaptcha-v3
2

Get your reCAPTCHA key

Register your site and get a reCAPTCHA V3 site key from the Google reCAPTCHA admin console.
Make sure to select reCAPTCHA v3 when creating your site key. V2 keys will not work with this library.
3

Wrap your app with the provider

Add GoogleReCaptchaProvider at the root of your component tree:
import { GoogleReCaptchaProvider } from 'react-google-recaptcha-v3';

function App() {
  return (
    <GoogleReCaptchaProvider reCaptchaKey="YOUR_SITE_KEY">
      <YourApp />
    </GoogleReCaptchaProvider>
  );
}
4

Execute reCAPTCHA verification

Use the useGoogleReCaptcha hook to verify user actions:
import { useGoogleReCaptcha } from 'react-google-recaptcha-v3';

function LoginForm() {
  const { executeRecaptcha } = useGoogleReCaptcha();

  const handleSubmit = async (e) => {
    e.preventDefault();
    
    if (!executeRecaptcha) {
      console.log('Execute recaptcha not yet available');
      return;
    }

    const token = await executeRecaptcha('login');
    // Send token to your backend for verification
  };

  return <form onSubmit={handleSubmit}>...</form>;
}

Key Features

Everything you need for seamless reCAPTCHA V3 integration

React Hooks

Modern React Hook API for programmatic verification

Context Provider

React Context-based provider for global reCAPTCHA management

TypeScript Support

Full TypeScript type definitions included out of the box

Enterprise Ready

Support for Google reCAPTCHA Enterprise edition

Customizable

Configure script loading, containers, and more

i18n Ready

Built-in internationalization support for global apps

Explore the Documentation

Find detailed guides and API references for all components

Components

Learn about GoogleReCaptchaProvider, GoogleReCaptcha, and more

API Reference

Comprehensive API documentation for all exports

Guides

Deep dive guides for advanced use cases

Examples

Real-world examples and code snippets

Ready to protect your app?

Start integrating Google reCAPTCHA V3 into your React application today.

Get Started

Build docs developers (and LLMs) love