google recaptcha

useGoogleReCaptcha

Hook for accessing reCAPTCHA functionality in React components

const {
  instance,
  isLoading,
  language,
  siteKey,
  executeV3,
  executeV2Invisible,
  reset,
  getResponse,
  render
} = useGoogleReCaptcha();

Values

PropertyTypeDescription
instanceReCaptchaInstance | nullThe reCAPTCHA instance.
isLoadingbooleanWhether the reCAPTCHA script is still loading.
languagestringThe language code used for reCAPTCHA.
siteKeystringThe site key used for reCAPTCHA.
executeV3(action?: string) => Promise<string>Executes reCAPTCHA v3 verification. Returns a promise that resolves to the verification token.
executeV2Invisible() => Promise<string>Executes reCAPTCHA v2 invisible verification. Returns a promise that resolves to the verification token.
reset() => voidResets the reCAPTCHA widget.
getResponse() => stringGets the current reCAPTCHA response token.
render() => voidRenders the reCAPTCHA widget.

On this page