Skip to content

Android Setup

Create an Android mobile application key in Google Cloud reCAPTCHA. Register the package name used by your Capacitor app, then set the key in capacitor.config.ts.

Android uses Google’s mobile reCAPTCHA SDK. Regular, non-Enterprise reCAPTCHA v3 is only available on Web in this plugin; enterprise: false is rejected on Android.

import type { CapacitorConfig } from '@capacitor/cli';
import '@capgo/capacitor-recaptcha';
const config: CapacitorConfig = {
plugins: {
Recaptcha: {
androidSiteKey: 'ANDROID_SITE_KEY',
},
},
};
export default config;

The plugin includes the Google Android reCAPTCHA dependency:

com.google.android.recaptcha:recaptcha:18.8.0

Google’s Android reCAPTCHA SDK requires core library desugaring in the consuming app. The plugin enables it automatically during npx cap sync android and adds:

com.android.tools:desugar_jdk_libs:2.1.5

You can override the dependency version from the app Gradle config with recaptchaVersion when you need to pin a newer Google SDK release. You can override the desugaring dependency with desugarJdkLibsVersion.

import { Recaptcha } from '@capgo/capacitor-recaptcha';
const { token } = await Recaptcha.execute({
action: 'checkout',
timeout: 10000,
});

Send the token to your backend immediately and create a reCAPTCHA assessment before accepting the protected request.