Empezar
Copiar un prompt de configuración con los pasos de instalación y la guía de markdown completa para este plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-recaptcha`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/recaptcha/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Instalar
Sección titulada “Instalar”npm install @capgo/capacitor-recaptchanpx cap syncConfigurar Claves de Sitio
Sección titulada “Configurar Claves de Sitio”Crea claves de plataforma en Google Cloud reCAPTCHA, luego agrega las a capacitor.config.ts.
import type { CapacitorConfig } from '@capacitor/cli';import '@capgo/capacitor-recaptcha';
const config: CapacitorConfig = { appId: 'com.example.app', appName: 'Example', webDir: 'dist', plugins: { Recaptcha: { androidSiteKey: 'ANDROID_SITE_KEY', iosSiteKey: 'IOS_SITE_KEY', webSiteKey: 'WEB_SITE_KEY', enterprise: true, }, },};
export default config;androidSiteKey, iosSiteKeyy webSiteKey sobreescribir la compartida siteKeyPuedes pasar un siteKey directamente a load() o execute() cuando la clave depende de tu entorno.
Generar un Token
Sección titulada “Generar un Token”import { Recaptcha } from '@capgo/capacitor-recaptcha';
const { token } = await Recaptcha.execute({ action: 'login',});
await fetch('/api/recaptcha-assessment', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ token, action: 'login' }),});execute() llamadas load() de manera automática cuando el cliente no está listo, por lo que un paso de carga explícita es opcional.
Estándar Web reCAPTCHA v3
Sección titulada “Estándar Web reCAPTCHA v3”Establecer enterprise: false para cargar el script estándar de Web reCAPTCHA v3 de Google.
const { token } = await Recaptcha.execute({ siteKey: 'WEB_V3_SITE_KEY', enterprise: false, action: 'signup',});On Android and iOS, Google’s native mobile SDK path is Enterprise/mobile only. Passing enterprise: false se rechaza en plataformas nativas, por lo que no se usa accidentalmente una clave Web estándar v3.
Notas de migración
Sección titulada “Notas de migración”El plugin acepta las antiguas opciones de Cordova con alias sitekeyAndroid y sitekeyWeb in call options and Capacitor config. It also accepts sitekeyIos y sitekeyIOS as iOS migration aliases. Prefer the Capacitor config names for new code.