Next.js 14 App Router,使用 server actions 与 useFormState 处理表单
resend-transactional-emails-starter — Next.js 启动器模板
作者 nazirabas
基于 Next.js 14 App Router、Resend 与 Zod 的联系表单邮件起始模板,包含表单校验、业务通知邮件与发件人确认邮件两套模板。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
用 Zod 校验并逐字段展示错误信息
通过 Resend SDK 发送邮件
内置通知邮件与确认邮件两套模板,无需 react-email 依赖
通知邮件设置 auto reply-to,回复直接发给提交者
模板渲染时对 HTML 实体做转义以处理 XSS
模板详细介绍
这是一个联系表单邮件流程的起始模板。README 说明它使用 Next.js 14 App Router 的 server actions 与 useFormState 处理表单提交,用 Zod 做校验并逐字段展示错误,通过 Resend SDK 发送邮件。邮件部分包含两个模板:发给业务的收件通知和发给表单提交者的确认邮件,模板为字符串形式的 HTML/文本渲染器,不依赖 react-email。通知邮件设置了 auto reply-to,回复会直接发给提交者;模板渲染时对 HTML 实体做转义以处理 XSS。
项目结构在 README 中列出:src/app/page.tsx 是使用 useFormState 与 useFormStatus 的联系表单,src/app/actions.ts 是 submitContact server action,src/lib/schemas.ts 存放 Zod 校验规则,emails/contact.tsx 是 HTML/文本模板渲染器。README 还给出了扩展方向,例如订单确认、密码重置、替换为 react-email 组件、添加附件或配合 Vercel Cron 定时发送,但这些属于建议,仓库本身未包含对应实现。
README 未提供关于性能、可访问性、测试覆盖、生产环境部署细节或框架具体版本号的说明;预览截图仅证明页面存在,不能据此推断页面功能。
适合你的项目吗?
适用场景
- 为网站搭建带校验与邮件通知的联系表单
- 需要同时向业务方和表单提交者发送邮件的场景
- 作为订单确认、密码重置等邮件流程的起点进行扩展
- 在 Next.js App Router 项目中接入 Resend 发送事务邮件
适合人群
- 使用 Next.js 14 App Router 的开发者
- 需要联系表单邮件流程起始代码的团队
- 希望在模板基础上自行扩展其他邮件类型的项目
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
克隆仓库后运行 npm install,并复制 .env.example 为 .env.local
- 2
在 .env.local 中配置 RESEND_API_KEY、FROM_EMAIL(Resend 中已验证的发件人)与 TO_EMAIL(接收咨询的邮箱)
- 3
运行 npm run dev 后打开 http://localhost:3000 提交表单,检查两个收件箱
- 4
未验证域名前,Resend 允许使用 [email protected] 作为测试发件人
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
- 运行前需在 .env.local 中配置 RESEND_API_KEY、FROM_EMAIL(Resend 已验证发件人)与 TO_EMAIL(接收咨询的邮箱)。
- 需要从 https://resend.com/api-keys 获取 Resend API 密钥,属于外部服务账号要求。
- FROM_EMAIL 必须是 Resend 中已验证的发件人地址。
- 未验证自有域名前,只能使用 [email protected] 作为测试发件人。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
# add RESEND_API_KEY, FROM_EMAIL (verified sender), TO_EMAIL (inbox)
README 原文
| `RESEND_API_KEY` | Get from https://resend.com/api-keys |
README 原文
| `FROM_EMAIL` | Verified sender in Resend (e.g. `[email protected]`) |
README 原文
https://github.com/nazirabas/resend-transactional-emails-starter/blob/main/LICENSEhttps://github.com/nazirabas/resend-transactional-emails-starter/blob/main/README.mdUntil you verify a domain, Resend allows sending from `[email protected]` for testing.
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-14。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 85 / 100
- 技术栈
- Next.js · HTML · React
- 网站类型
- 启动器
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-07-16
- 截图检查日期
- 2026-10-16
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
审核声明: codex-user-requested-batch-review-20261017 · 2026-10-16
查看当时使用的来源资料
SHA-256: a1fd2316595247f1420fff164d354120b3d39cd3a6124c4b41d8ea9b582ba1fe
2026-10-14T22:44:32.140Z
来源文件 / 仓库# Resend Transactional Emails Starter Next.js 14 + Resend + Zod, wired for a real-world contact form flow: validation, notification email to the business, confirmation email to the sender. Templates included, no `react-email` dependency required.  **Live demo:** [resend-transactional-emails-starter.vercel.app](https://resend-transactional-emails-starter.vercel.app) ## What's included - **Next.js 14** App Router with server actions and `useFormState` - **Resend** SDK for delivery - **Zod** validation with per-field error surfacing - **Two email templates** (notification + confirmation) with luxury dark-and-gold design - **Auto reply-to** — replies to the notification email go straight to the sender - **XSS-safe** HTML rendering with entity escaping in templates ## Quick start ```bash git clone https://github.com/nazirabas/resend-transactional-emails-starter my-forms cd my-forms npm install cp .env.example .env.local # add RESEND_API_KEY, FROM_EMAIL (verified sender), TO_EMAIL (inbox) npm run dev ``` Open http://localhost:3000, submit the form. Check both inboxes. ## Environment variables | Variable | Description | |---|---| | `RESEND_API_KEY` | Get from https://resend.com/api-keys | | `FROM_EMAIL` | Verified sender in Resend (e.g. `[email protected]`) | | `TO_EMAIL` | Where inbound enquiries land (your inbox) | Until you verify a domain, Resend allows sending from `[email protected]` for testing. ## Structure ``` src/app/ page.tsx # Contact form with useFormState + useFormStatus actions.ts # submitContact server action layout.tsx src/lib/ schemas.ts # Zod validation schema emails/ contact.tsx # HTML/text template renderers ``` ## Extending - **Order confirmations** — add a `renderOrderConfirmation` in `emails/order.tsx`, call from a Stripe webhook route - **Password reset** — same pattern, add a token in the URL - **React Email** — swap the string templates for `react-email` components if you want richer previews - **Attachments** — pass `attachments: [{ filename, content }]` to `resend.emails.send` - **Scheduled sends** — pair with Vercel Cron for reminder emails ## License MIT. --- Built by [Nazir Abbas](https://github.com/nazirabas). Web Developer and SEO Specialist for luxury brands.
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

ai-website-cloner-template
Clone any website with one command using AI coding agents
Next.js · 启动器

Next.js SaaS Starter
Next.js SaaS Starter 是 Next.js 官方维护的 SaaS 起点模板,定位介于学习资源和可直接部署的脚手架之间。
Next.js · SaaS

Next.js Commerce
Next.js Commerce 是 Vercel 团队维护的电商启动模板,基于 Next.js App Router 构建,采用服务端渲染、React Server Components、Server Actions …
Next.js · 电商

Next-js-Boilerplate
Next-js-Boilerplate 是一个面向 Next.js 16、Tailwind CSS 4 和 TypeScript 的启动器,核心定位是开发者体验优先。
Next.js · 启动器

tailwind-nextjs-starter-blog
tailwind-nextjs-starter-blog 是一个面向个人技术博客的 Next.js 与 Tailwind CSS 启动模板,其 v2 版本基于 App Router 与 React Server Comp…
Next.js · 博客

next-forge
Production-grade Turborepo template for Next.js apps.
Next.js · 启动器
