Skip to main content

Migrate from 1.0 to 2.0

Version 2.0 introduced breaking changes to simplify the API and improve the language configuration system. This guide will help you update your code to work with the new version.

Breaking Changes

Removed Options: The following global configuration options have been removed in v2.0:
  • options.removeOnUnmount
  • options.lang

Language Configuration

Before (v1.0):
import ReCAPTCHA from "react-google-recaptcha";

// Language was configured via options.lang
ReCAPTCHA.configure({
  lang: 'fr'
});

function MyComponent() {
  return <ReCAPTCHA sitekey="your_site_key" />;
}
After (v2.0):
import ReCAPTCHA from "react-google-recaptcha";

// Language is now passed directly as the 'hl' prop
function MyComponent() {
  return (
    <ReCAPTCHA 
      sitekey="your_site_key" 
      hl="fr" 
    />
  );
}

Migration Steps

1

Remove global configuration

Remove any calls to ReCAPTCHA.configure() that set lang or removeOnUnmount options.
2

Update language prop

Replace options.lang configuration with the hl prop directly on the <ReCAPTCHA> component.
<ReCAPTCHA sitekey="your_site_key" hl="es" />
3

Test your implementation

Verify that reCAPTCHA renders correctly with your specified language and that all functionality works as expected.

Why These Changes?

The removeOnUnmount option was only useful for language changes, which are now handled more elegantly through the hl prop. This simplifies the API and makes language configuration more React-like by using props instead of global configuration.

Additional Resources

Build docs developers (and LLMs) love