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>
);
}
Hook that wires together:
validate()function for client-side checks before submission