集成 NextAuth.js 邮箱密码认证与 JWT 会话,附带注册、登录和受保护仪表盘页面
Christophers-Next-Template — Next.js 启动器模板
作者 christopherrobin
一个带邮箱密码认证、Postgres 数据层与完整测试分层的 Next.js 启动器,采用 MIT 许可,适合作为全栈应用的初始骨架。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
使用 Prisma 连接 PostgreSQL,包含 schema 与迁移文件
通过 Zod 与 react-hook-form 在客户端和服务端共享表单校验规则
包含 Jest + Testing Library 单元/组件测试与 Playwright 端到端测试
配置 ESLint、Prettier 与 Next 16 的 proxy 中间件做路由保护
采用 MIT 许可,代码可免费使用、修改和分发
模板详细介绍
Christophers-Next-Template 是一个面向全栈 Web 应用的 Next.js 启动器,重点放在认证与工程化配置上。它使用 App Router,集成 NextAuth.js 的邮箱密码登录与 JWT 会话,通过 Prisma 连接 PostgreSQL 存储用户数据,并用 Zod 与 react-hook-form 共享客户端和服务端的表单校验规则。项目自带注册、登录、受保护仪表盘以及 404 页面,路由保护由 Next 16 的 proxy 中间件实现:未登录访问 /dashboard 会跳转到登录页,已登录访问登录或注册页会跳回仪表盘。
工程化方面,仓库包含 ESLint、Prettier、Jest 与 Testing Library 的单元/组件测试,以及 Playwright 的端到端测试,测试文件与源码就近放置。README 说明需要 Node.js 24+ 和 PostgreSQL,并列出三个环境变量:DATABASE_PUBLIC_URL、NEXTAUTH_SECRET、NEXTAUTH_URL。项目以 MIT 许可发布,代码可免费使用、修改和分发,但演示图片、字体、图标等第三方素材以及数据库、托管等外部服务需另行核对许可与费用。
适合你的项目吗?
适用场景
- 需要快速搭建带邮箱密码认证的全栈 Next.js 应用原型
- 希望以 Prisma + PostgreSQL 作为数据层起步的项目
- 需要同时具备单元测试和端到端测试配置的初始工程
- 想参考 Next.js App Router 下中间件路由保护与表单校验的组织方式
适合人群
- 熟悉 Next.js、TypeScript 和 Prisma 的开发者
- 需要可扩展认证骨架的全栈项目
- 希望自带测试分层与代码规范配置的团队
- 能自行准备 PostgreSQL 数据库和托管环境的用户
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
需要 Node.js 24+,仓库提供 .nvmrc 可运行 nvm use
- 2
需要准备 PostgreSQL 数据库连接
- 3
复制 .env.local.example 为 .env.local,填写 DATABASE_PUBLIC_URL、NEXTAUTH_SECRET 和 NEXTAUTH_URL
- 4
使用 yarn install 安装依赖,yarn prisma migrate deploy 执行迁移,yarn dev 启动开发服务器
- 5
演示图片、字体、图标等第三方素材需按各自许可核对,数据库与托管等外部服务可能另外收费
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
- 使用该模板需要 Node.js 24 或更高版本,并自行准备 PostgreSQL 数据库,属于运行环境要求。
- 必须配置 DATABASE_PUBLIC_URL、NEXTAUTH_SECRET、NEXTAUTH_URL 三个环境变量,否则无法正常连接数据库与认证服务。
- 需将 .env.local.example 复制为 .env.local 并填写数据库与密钥值,属于部署前的必要配置步骤。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
- Node.js 24+ (a `.nvmrc` is provided — run `nvm use`) - PostgreSQL database
README 原文
- `DATABASE_PUBLIC_URL` — PostgreSQL connection string - `NEXTAUTH_SECRET` — Secret for NextAuth.js (generate with `openssl rand -base64 32`) - `NEXTAUTH_URL` — Canonical site URL (e.g. `http://localhost:3000`)
README 原文
https://github.com/christopherrobin/Christophers-Next-Template/blob/main/LICENSEhttps://github.com/christopherrobin/Christophers-Next-Template/blob/main/README.md3. Configure environment variables: - Copy `.env.local.example` to `.env.local` and fill in your database and secret values.
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-06。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 85 / 100
- 技术栈
- Next.js · React
- 网站类型
- 启动器
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-10-05
- 截图检查日期
- 2026-10-06
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
审核声明: [email protected] · 2026-10-06
查看当时使用的来源资料
SHA-256: 76973fe6af69b21412117f4531f77fb6fe798e00a4682e1a920962079a97b786
2026-10-06T00:08:13.834Z
来源文件 / 仓库# Christophers-Next-Template [](https://github.com/christopherrobin/Christophers-Next-Template/actions/workflows/ci.yml) [](https://jestjs.io/) [](https://playwright.dev/) [](https://github.com/christopherrobin/Christophers-Next-Template/blob/main/jest.config.ts) [](https://github.com/christopherrobin/Christophers-Next-Template/blob/main/eslint.config.mjs) [](https://github.com/christopherrobin/Christophers-Next-Template/blob/main/.prettierrc) [](https://nextjs.org/) [](https://react.dev/) [](https://www.typescriptlang.org/) [](https://tailwindcss.com/) [](https://www.prisma.io/) [](https://www.postgresql.org/) [](https://next-auth.js.org/)  ## A modern, minimal authentication starter for developers, built with Next.js, TypeScript, Prisma, and Tailwind CSS. **Howdy!** This starter kit is designed for those who want a clean, extensible foundation for building modern, full-stack web applications with authentication using Next.js 16, TypeScript, Prisma, and Tailwind CSS. ## Stack - **Next.js 16** with App Router (Turbopack default) - **React 19**, **TypeScript 6** (strict) - **Prisma 7** with PostgreSQL - **Tailwind CSS 4** for styling - **NextAuth.js 4** for authentication (email & password, JWT sessions) - **Zod + react-hook-form** for form validation (shared client/server schemas) - **Heroicons** for modern SVG icons - **bcrypt** (via bcryptjs) for secure password hashing ## Tooling & Features - **ESLint** and **Prettier** for code quality - **Unit & Component Testing** with Jest & Testing Library - **End-to-End (E2E) Testing** with Playwright - User registration and login flows - Protected dashboard for authenticated users ## Getting Started Clone and set up the project in minutes: ### Prerequisites - Node.js 24+ (a `.nvmrc` is provided — run `nvm use`) - PostgreSQL database ### Installation 1. Clone the repository: ```bash git clone https://github.com/christopherrobin/Christophers-Next-Template cd Christophers-Next-Template ``` 2. Install dependencies: ```bash yarn install ``` 3. Configure environment variables: - Copy `.env.local.example` to `.env.local` and fill in your database and secret values. 4. Run Prisma migrations: ```bash yarn prisma migrate deploy ``` 5. Start the development server: ```bash yarn dev ``` Visit [http://localhost:3000](http://localhost:3000) to view the app. ## Project Structure - `src/app/` — Next.js App Router pages (home, sign-up, sign-in, dashboard, `not-found.tsx`) - `src/components/` — Reusable UI components (Button, Input, Spinner, GitHubIcon, Providers) - `src/lib/` — Prisma client, NextAuth config, env validation (`env.ts`), API helpers (`api-utils.ts`), shared Zod schemas (`schemas.ts`) - `src/proxy.ts` — Next 16 middleware (route protection and auth redirects) - `prisma/` — Prisma schema and migrations - `public/` — Static assets and icons - `e2e/` — End-to-end tests Unit/component tests are co-located next to source files (e.g. `Button.tsx` + `Button.test.tsx`). ## Customization Extend or modify any part to fit your project: - Add new pages or API routes in `src/app/` - Create custom UI components in `src/components/` - Adjust authentication logic in `src/lib/auth.ts` - Update styles via Tailwind config or CSS ## Scripts - `yarn dev` — Start development server - `yarn build` — Build for production - `yarn start` — Start production server - `yarn prisma:migrate` — Deploy database migrations - `yarn lint` / `yarn lint:fix` — Lint code - `yarn format` / `yarn format:fix` — Format code - `yarn run nuke` — Remove node_modules, reinstall dependencies, and rebuild - `yarn run clean` — Lint, format, and prettify all code ## Environment Variables - `DATABASE_PUBLIC_URL` — PostgreSQL connection string - `NEXTAUTH_SECRET` — Secret for NextAuth.js (generate with `openssl rand -base64 32`) - `NEXTAUTH_URL` — Canonical site URL (e.g. `http://localhost:3000`) ## Authentication & Routing The included `src/proxy.ts` (Next 16's renamed middleware) enforces: - `/dashboard/*` requires authentication (unauth users are redirected to `/sign-in?callbackUrl=...`) - `/sign-in` and `/sign-up` redirect authenticated users to `/dashboard` - `/` is public for everyone ## Forms & Validation Sign-in and sign-up forms use **react-hook-form + Zod** via `zodResolver`. Schemas live in `src/lib/schemas.ts` and are used by both the client form and the server-side `safeParse` in `/api/sign-up/route.ts` — one source of truth, type-inferred via `z.infer`. Forms set `noValidate` so RHF owns validation (not native HTML5). ## Using Heroicons This project uses [Heroicons](https://heroicons.com/) for modern SVG icons in React components. ### How to Use Heroicons - The `@heroicons/react` package is installed as a dependency. - Import icons into your components. There are two main styles and sizes. - Use icons as React components, e.g. `<RocketLaunchIcon className="w-5 h-5" />`. - The custom `Button` component supports passing icons as `startIcon` or `endIcon` props. For more icons and usage details, see the [Heroicons documentation](https://heroicons.com/). ## Testing This project supports two main testing methods: - **Unit & Component Testing** (Jest + Testing Library): - Run all tests: `yarn test` - Run a specific test file: `yarn test src/components/Button.test.tsx` - Tests are co-located next to the components they cover (e.g. `Button.tsx` + `Button.test.tsx`). - Uses [@testing-library/react](https://testing-library.com/docs/react-testing-library/intro/) and [@testing-library/user-event](https://testing-library.com/docs/ecosystem-user-event/) for React component interaction and assertions. - **End-to-End (E2E) Testing** (Playwright): - Run all E2E tests: `yarn test:e2e` - Specs live in the `e2e/` directory. - Uses [Playwright](https://playwright.dev/) for browser-based end-to-end testing. ## License This project is open source and available under the [MIT License](LICENSE).
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

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 · 启动器
