import { createClient, type VerifyInput } from '@private-captcha/private-captcha-js';
const client = createClient({ apiKey: 'YOUR_API_KEY' });
// Run this on the server, before any business logic.
export async function submitForm(formData: FormData): Promise<void> {
const solution = formData.get('private-captcha-solution');
if (typeof solution !== 'string') {
throw new Error('Captcha solution is missing');
}
const input: VerifyInput = {
solution,
sitekey: 'YOUR_SITEKEY',
};
const result = await client.verify(input);
if (!result.ok()) {
throw new Error(`Captcha verification failed: ${result.code}`);
}
// Verification passed. Process your form submission here.
}