react-honeypot-field
    Preparing search index...

    Function validateHoneypot

    • Server-side honeypot validation.

      Use this in your API route / server action after the client passes fieldValue and optionally mountedAt in the request body.

      Parameters

      Returns ServerHoneypotResult

      // app/api/contact/route.ts
      import { validateHoneypot } from 'react-honeypot-field/validate';

      export async function POST(req: Request) {
      const body = await req.json();

      const hp = validateHoneypot({
      fieldValue: body.website,
      mountedAt: body._mountedAt,
      submittedAt: Date.now(),
      });

      if (!hp.ok) {
      // Silently return 200 — don't reveal to the bot that it failed
      return Response.json({ ok: true });
      }

      // ... process the real form
      }
      app.post('/contact', (req, res) => {
      const hp = validateHoneypot({
      fieldValue: req.body.website,
      mountedAt: req.body._mountedAt,
      submittedAt: Date.now(),
      });

      if (!hp.ok) return res.json({ ok: true }); // silent drop

      // ... process the real form
      });