A simple Next.js, TypeScript, and Tailwind CSS contact form template powered by the Resend API. Validated with Zod, submitted via Next.js Server Actions, and includes toast notifications using Sonner.
https://resend-email-template.vercel.app/
- Original post (first version): https://www.jorge-perez.dev/blog/resend-contact-form
- Updated post (Next.js 16 + React 19 + Server Actions refactor): https://www.jorge-perez.dev/blog/resend-contact-updated
- Next.js 16 (App Router)
- React 19
- Resend Email API
- Server-side validation with Zod
- Form submissions using Next.js Server Actions (
useActionState) - Pending UI state with
useFormStatus - Toast notifications with Sonner
replyToset to the sender email for easy replies- Basic spam protection via honeypot field
- Improved metadata configuration (
metadataBase) for correct OG/Twitter previews
This template requires a Resend API key and a verified domain or sender identity:
- Create an API key: https://resend.com/api-keys
- Verify your domain: https://resend.com/domains
Bootstrap this example using create-next-app:
npx create-next-app --example https://github.com/JPerez00/resend-email-template your-project-name-hereCreate a .env.local file in the root of the project:
RESEND_API_KEY=your_resend_api_key_here
EMAIL_FROM="Your Website Name <noreply@your-domain.com>"
EMAIL_TO=your_destination_email@example.comRun the dev server:
npm run devWhen deploying to Vercel, add the same environment variables:
RESEND_API_KEY=your_resend_api_key_here
EMAIL_FROM=Your Website Name <noreply@your-domain.com>
EMAIL_TO=your_destination_email@example.comInclude quotes locally in .env.local, but omit them in Vercel Environment Variables:
- Locally:
EMAIL_FROM="Coding SaaS <noreply@codingsaas.com>" - Vercel:
EMAIL_FROM=Coding SaaS <noreply@codingsaas.com>
See Vercel deployment example below:
This template uses social preview images (Open Graph / Twitter).
For the cleanest production previews, you can set:
NEXT_PUBLIC_SITE_URL=https://your-domain.comLocally you can use:
NEXT_PUBLIC_SITE_URL=http://localhost:3000Main files you’ll care about:
app/components/ContactForm.tsx(form UI)app/actions.ts(Server Action that validates and sends the email)app/emails/ContactFormEmail.tsx(email template)lib/schema.ts(Zod validation schema)lib/env.server.ts(server-only env validation)app/layout.tsx(global layout + metadata)
This project uses next/font to automatically optimize and load Inter.
- Next.js Docs: https://nextjs.org/docs
- Resend Docs: https://resend.com/docs/introduction
- Zod Docs: https://zod.dev/
You can also check out the Next.js GitHub repo: https://github.com/vercel/next.js/

