react-honeypot-field
    Preparing search index...

    Function useHoneypot

    • Hook that wires together:

      1. A ref for the hidden honeypot input element
      2. A mount timestamp for time-threshold validation
      3. A validate() function for client-side checks before submission

      Parameters

      Returns UseHoneypotReturn

      function ContactForm() {
      const { fieldProps, validate, mountedAt } = useHoneypot();

      function handleSubmit(e: React.FormEvent) {
      e.preventDefault();
      const result = validate();
      if (!result.ok) return; // silent drop — don't alert bots

      // include mountedAt in your API payload for server-side check
      await fetch('/api/contact', {
      body: JSON.stringify({ ...formData, _mountedAt: mountedAt }),
      });
      }

      return (
      <form onSubmit={handleSubmit}>
      <HoneypotField {...fieldProps} />
      ...
      </form>
      );
      }