Skip to main content

What is react-google-recaptcha?

react-google-recaptcha is a React component library that provides an easy-to-use wrapper for Google reCAPTCHA v2. It allows you to quickly integrate CAPTCHA verification into your React applications to protect forms from spam and abuse. The library handles the complexity of loading the Google reCAPTCHA script asynchronously and provides a clean, declarative React API for interacting with the CAPTCHA widget.

Why Use This Library?

Simple Integration

Drop-in React component with minimal configuration required - just add your site key and you’re ready to go

Multiple Size Options

Support for normal, compact, and invisible CAPTCHA modes to fit your UI requirements

Ref API Access

Programmatic control through ref methods like execute(), reset(), and getValue()

TypeScript Ready

Full TypeScript support with comprehensive prop types and type definitions

Key Features

Automatic Script Loading

The library automatically loads the Google reCAPTCHA script asynchronously, so you don’t need to manually add script tags to your HTML. It uses react-async-script internally to handle script injection.

Flexible CAPTCHA Types

Supports all reCAPTCHA v2 configurations:
  • Normal - Standard CAPTCHA widget (default)
  • Compact - Smaller widget for mobile or constrained spaces
  • Invisible - No visible widget, triggered programmatically

Theme and Localization

Customize the appearance with light/dark themes and support for multiple languages through the hl (language) parameter.

Enterprise Support

Built-in support for Google reCAPTCHA Enterprise by setting window.recaptchaOptions.enterprise = true.

Network Flexibility

When google.com is blocked, automatically switch to recaptcha.net by configuring window.recaptchaOptions.useRecaptchaNet = true.

reCAPTCHA v2 vs v3

This library is specifically designed for reCAPTCHA v2, which requires user interaction (checkbox or challenge). If you need reCAPTCHA v3 (score-based, no user interaction), you’ll need a different library.
reCAPTCHA v2 provides:
  • Checkbox verification - “I’m not a robot” checkbox
  • Image challenges - Select images matching a criteria
  • Audio challenges - Alternative for accessibility
  • Invisible mode - Triggered programmatically without visible widget

Next Steps

Installation

Install the library and get your API keys

Quick Start

Build your first reCAPTCHA-protected form

Additional Resources

Google reCAPTCHA Docs

Official Google reCAPTCHA v2 documentation

Get API Keys

Register your site and obtain API keys

Build docs developers (and LLMs) love