reCAPTCHA Package
Package: @nauth-toolkit/recaptcha
Type: Provider Package
Google reCAPTCHA bot protection with support for v2 (checkbox), v3 (score-based), and Enterprise.
Installation
- npm
- Yarn
- pnpm
- Bun
npm install @nauth-toolkit/recaptcha
```
yarn add @nauth-toolkit/recaptcha
```
pnpm add @nauth-toolkit/recaptcha
```
bun add @nauth-toolkit/recaptcha
```
Quick Start
- NestJS
- Express
- Fastify
import { NAuthModule } from '@nauth-toolkit/nestjs';
import { RecaptchaEnterpriseProvider } from '@nauth-toolkit/recaptcha';
@Module({
imports: [
NAuthModule.forRoot({
recaptcha: {
enabled: true,
provider: new RecaptchaEnterpriseProvider({
projectId: process.env.RECAPTCHA_PROJECT_ID!,
apiKey: process.env.RECAPTCHA_API_KEY!,
siteKey: process.env.RECAPTCHA_SITE_KEY!,
}),
minimumScore: 0.5,
},
}),
],
})
export class AppModule {}
import { NAuth } from '@nauth-toolkit/core';
import { ExpressAdapter } from '@nauth-toolkit/express';
import { RecaptchaEnterpriseProvider } from '@nauth-toolkit/recaptcha';
const nauth = await NAuth.create({
config: {
recaptcha: {
enabled: true,
provider: new RecaptchaEnterpriseProvider({
projectId: process.env.RECAPTCHA_PROJECT_ID!,
apiKey: process.env.RECAPTCHA_API_KEY!,
siteKey: process.env.RECAPTCHA_SITE_KEY!,
}),
minimumScore: 0.5,
},
},
dataSource,
adapter: new ExpressAdapter(),
});
import { NAuth } from '@nauth-toolkit/core';
import { FastifyAdapter } from '@nauth-toolkit/fastify';
import { RecaptchaEnterpriseProvider } from '@nauth-toolkit/recaptcha';
const nauth = await NAuth.create({
config: {
recaptcha: {
enabled: true,
provider: new RecaptchaEnterpriseProvider({
projectId: process.env.RECAPTCHA_PROJECT_ID!,
apiKey: process.env.RECAPTCHA_API_KEY!,
siteKey: process.env.RECAPTCHA_SITE_KEY!,
}),
minimumScore: 0.5,
},
},
dataSource,
adapter: new FastifyAdapter(),
});
Providers
- RecaptchaV2Provider - Checkbox-based verification
- RecaptchaV3Provider - Score-based, invisible
- RecaptchaEnterpriseProvider - Advanced Enterprise features
Version Comparison
| Feature | v2 | v3 | Enterprise |
|---|---|---|---|
| User Interaction | Yes (checkbox) | No | No |
| Score-based | No | Yes | Yes |
| Custom Rules | No | No | Yes |
| Analytics | Basic | Basic | Advanced |
| SLA | No | No | Yes |
| Setup Complexity | Low | Medium | High |
When to Use
- v2: Simple protection, acceptable user friction
- v3: Invisible protection, score-based decisions
- Enterprise: High-traffic, advanced security, compliance needs
Related
- RecaptchaConfig Interface - Configuration options
- reCAPTCHA Guide - Complete implementation guide