How ozcancelik/nextjs-14-mail-form works
Project type and purpose
• This is a full-stack Next.js 14 template for a contact form.
• It provides a React-based frontend (in src/app), uses Next.js Server Actions (in src/app/actions.ts) for form submission, validates input with Zod, protects from spam with reCAPTCHA, formats emails with Handlebars (src/templates/contact.ts), and sends mail via Nodemailer through a custom Node.js server (server.js).
File structure
• Top‐level files:
• server.js – custom Node HTTP server that mounts Next.js
• next.config.mjs – Next.js configuration
• .env.example – environment variables for SMTP, reCAPTCHA, port
• package.json, build/config files (Tailwind, PostCSS, ESLint, TS)
• public/ – static assets (e.g., favicon, robots.txt)
• src/app/ – Next.js App Router: layouts, global CSS, page.tsx (UI) and actions.ts (Server Actions)
• src/components/ – UI components (form, toast notifications)
• src/lib/utils.ts – shared helper functions
• src/templates/ – Handlebars email templates
README for architecture clues
• Confirms stack: Next.js Server Actions, React Hook Form, Zod, reCAPTCHA v2, Handlebars, Nodemailer, Tailwind CSS, TypeScript.
• Notes that @/app/actions.ts contains sendContactForm which:
1. Validates form data via Zod
2. Verifies reCAPTCHA server-side
3. Uses Handlebars to render HTML email
4. Sends email via Nodemailer to external SMTP
Essential details
• Handlebars template engine reading contact.ts and producing HTML.
• Don’t overthink—break the system into these discrete components for clarity.
• Flows (success and error) are represented, even if simply noted as “error path.”