Neviditelná CAPTCHA pro React & Next.js
NPM balíček s podporou TypeScript, React Hooks API a kompatibilitou s Next.js SSR. Pouze 3KB gzipped.

Vývojářský zážitek
Nativní TypeScript – plná typová bezpečnost
React Hooks API – Hook useSilentShield()
Kompatibilní s Next.js SSR – funguje s App Router
Velikost balíčku: pouze 3KB gzipped
Tree-shakeable – pouze to, co potřebujete
Žádné závislosti – žádný bloat
Příklady kódu
Instalace
npm install @silentshield/reactReact 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...
}Vzor Provider
import { SilentShieldProvider } from '@silentshield/react';
function App() {
return (
<SilentShieldProvider siteKey="YOUR_SITE_KEY">
<MyApp />
</SilentShieldProvider>
);
}Integrujte s React nyní
npm install @silentshield/react – připraveno za 5 minut.