Almost every business website needs a contact form, and almost every contact form ends up as a target for bots. In the Next.js App Router you no longer need a separate API route for this: a Server Action can receive the form, validate it and send the enquiry, while the page keeps working even before JavaScript loads.
This tutorial builds that form step by step:
A plain form component
A Server Action that receives it
Validation with Zod
A honeypot field and a timing check for bots
Field errors and a pending state with useActionState
It assumes Next.js 15 or later (React 19) with the App Router and TypeScript. Install Zod with npm install zod .
1. The form component
Start with a normal HTML form.…