useGoogleReCaptchaProvider

useGoogleReCaptchaProvider

Composable for managing Google reCAPTCHA provider state in Vue applications

const googleReCaptcha = useGoogleReCaptchaProvider({
  type
  siteKey
  language
  scriptProps
  isEnterprise
  host
  theme
  explicit
  onLoad
  onError
});

Parameters

ParameterTypeRequiredDefaultDescription
type'v2-checkbox' | 'v2-invisible' | 'v3'Yes-The type of reCAPTCHA to use
siteKeystringYes-Your Google reCAPTCHA site key
languagestring--Language code for the reCAPTCHA widget
scriptPropsGoogleReCaptcha.Script--Additional properties for the reCAPTCHA script
isEnterpriseboolean-falseWhether to use reCAPTCHA Enterprise
hoststring--Custom host for the reCAPTCHA script
theme'light' | 'dark'-lightTheme of the reCAPTCHA widget
explicitboolean | ExplicitOptions--Whether to use explicit rendering
onLoad(instance: GoogleReCaptcha.Instance) => void--Callback when reCAPTCHA is loaded
onError() => void--Callback when an error occurs

Return Value

PropertyTypeDescription
instanceGoogleReCaptcha.Instance | undefinedThe reCAPTCHA instance.
isLoadingbooleanWhether the reCAPTCHA script is still loading.
languagestring | undefinedThe 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(optWidgetId?: string) => Promise<void>Executes reCAPTCHA v2 invisible verification.
reset(optWidgetId?: string) => voidResets the reCAPTCHA widget.
getResponse(optWidgetId?: string) => stringGets the current reCAPTCHA response token.
render(container: string | HTMLElement, parameters?: GoogleReCaptcha.Parameters, inherit?: boolean) => numberRenders the reCAPTCHA widget.

Last updated on