Invisible CAPTCHA for React & Next.js

NPM package with TypeScript support, React Hooks API, and Next.js SSR compatibility. Only 3KB gzipped.

React CAPTCHA Integration

Developer Experience

TypeScript-native – full type safety
React Hooks API – useSilentShield() Hook
Next.js SSR-compatible – works with App Router
Bundle size: only 3KB gzipped
Tree-shakeable – only what you need
Zero dependencies – no bloat

Code Examples

Installation

npm install @silentshield/react

React Hook API

import { useSilentShield } from '@silentshield/react';

function ContactForm() {
  const { verify, isVerifying } = useSilentShield({
    siteKey: 'YOUR_SITE_KEY',
  });

  const handleSubmit = async (e: FormEvent) => {
    e.preventDefault();
    const token = await verify();

    // Send token to backend
    await fetch('/api/contact', {
      method: 'POST',
      body: JSON.stringify({ ...formData, token }),
    });
  };

  return (
    <form onSubmit={handleSubmit}>
      {/* Your form fields */}
      <button disabled={isVerifying}>
        Submit
      </button>
    </form>
  );
}

Next.js App Router

// app/api/contact/route.ts
import { verifySilentShield } from '@silentshield/node';

export async function POST(req: Request) {
  const { token, ...data } = await req.json();

  const result = await verifySilentShield({
    secret: process.env.SILENTSHIELD_SECRET!,
    token,
  });

  if (!result.success) {
    return Response.json(
      { error: 'Bot detected' },
      { status: 403 }
    );
  }

  // Process form data...
}

Provider Pattern

import { SilentShieldProvider } from '@silentshield/react';

function App() {
  return (
    <SilentShieldProvider siteKey="YOUR_SITE_KEY">
      <MyApp />
    </SilentShieldProvider>
  );
}

Integrate with React now

npm install @silentshield/react – ready in 5 minutes.