Next.js App Router 与 React、TypeScript 严格模式组合
Christophers-Next-MUI-Template — Next.js 启动器模板
作者 christopherrobin
基于 Next.js App Router 的认证启动器,集成 Material UI、Prisma + PostgreSQL 与 NextAuth,附带 Jest 与 Playwright 测试配置。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
Material UI 深色主题,Geist 字体接入 MUI typography
NextAuth.js 邮箱密码认证与 JWT 会话
Prisma + PostgreSQL 数据层,含迁移脚本
react-hook-form + Zod 共享客户端与服务端校验 schema
Jest 单元/组件测试与 Playwright 端到端测试
模板详细介绍
这是一个面向全栈应用的认证启动模板,使用 Next.js App Router 组织页面,UI 层采用 Material UI 并配置了自定义深色主题,字体使用 Geist 并接入 MUI 主题。数据层通过 Prisma 连接 PostgreSQL,认证由 NextAuth.js 负责,采用邮箱加密码的登录方式与 JWT 会话。表单校验使用 react-hook-form 与 Zod,客户端与服务端共享同一套 schema。
模板内置注册、登录以及受保护的仪表盘页面,并通过 Next.js 中间件(src/proxy.ts)控制路由访问:/dashboard/* 需要登录,未登录用户会被重定向到 /sign-in 并携带 callbackUrl;/sign-in 与 /sign-up 对已登录用户会跳转到 /dashboard;首页对所有访客开放。
测试方面同时提供 Jest + Testing Library 的单元与组件测试,以及 Playwright 的端到端测试,单元测试文件与源码同目录存放。项目使用 ESLint 与 Prettier 管理代码质量,并提供了开发、构建、数据库迁移、格式化等脚本。
使用前需要准备 Node.js 24+ 与 PostgreSQL 数据库,并配置 DATABASE_PUBLIC_URL、NEXTAUTH_SECRET、NEXTAUTH_URL 三个环境变量。仓库采用 MIT 许可,但演示图片、字体、图标等第三方素材以及数据库、托管等外部服务需另行核对许可与费用。
适合你的项目吗?
适用场景
- 需要快速搭建带注册登录的全栈应用原型
- 希望以 Material UI 深色主题为起点定制界面
- 需要 Prisma + PostgreSQL 与 NextAuth 组合的参考实现
- 想同时配置单元测试与端到端测试的项目
- 需要基于中间件做路由保护与登录重定向的示例
适合人群
- 熟悉 Next.js App Router 与 TypeScript 的开发者
- 需要认证与数据库起步模板的全栈项目
- 偏好 Material UI 组件库的团队
- 希望项目自带测试配置的开发者
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 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 执行迁移
- 5
yarn dev 启动开发服务器,默认访问 http://localhost:3000
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
- 使用该模板需要 Node.js 24 或更高版本,低于此版本的环境无法按文档运行。
- 项目依赖 PostgreSQL 数据库,必须自行准备可用的 PostgreSQL 实例才能运行。
- 必须配置 DATABASE_PUBLIC_URL 环境变量,提供 PostgreSQL 连接字符串。
- 必须配置 NEXTAUTH_SECRET 环境变量,用于 NextAuth.js 会话加密。
- 必须配置 NEXTAUTH_URL 环境变量,指定站点的规范 URL。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
- Node.js 24+ (a `.nvmrc` is provided — run `nvm use`)
README 原文
- PostgreSQL database
README 原文
- `DATABASE_PUBLIC_URL` — PostgreSQL connection string
README 原文
- `NEXTAUTH_SECRET` — Secret for NextAuth.js (generate with `openssl rand -base64 32`)
README 原文
https://github.com/christopherrobin/Christophers-Next-MUI-Template/blob/main/LICENSEhttps://github.com/christopherrobin/Christophers-Next-MUI-Template/blob/main/README.md- `NEXTAUTH_URL` — Canonical site URL (e.g. `http://localhost:3000`)
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: b67336db88b06dd423858ec55844fc8ed954b3b0d0faf05bccec0e8024b76898
2026-10-06T00:07:53.642Z
来源文件 / 仓库# Christophers-Next-MUI-Template
[](https://github.com/christopherrobin/Christophers-Next-MUI-Template/actions/workflows/ci.yml)
[](https://jestjs.io/)
[](https://playwright.dev/)
[](https://github.com/christopherrobin/Christophers-Next-MUI-Template/blob/main/jest.config.ts)
[](https://github.com/christopherrobin/Christophers-Next-MUI-Template/blob/main/eslint.config.mjs)
[](https://github.com/christopherrobin/Christophers-Next-MUI-Template/blob/main/.prettierrc)
[](https://nextjs.org/)
[](https://react.dev/)
[](https://www.typescriptlang.org/)
[](https://mui.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 Material UI.
**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 Material UI.
## Stack
- **Next.js 16** with App Router (Turbopack default)
- **React 19**, **TypeScript 6** (strict)
- **Prisma 7** with PostgreSQL
- **Material UI 9** with Emotion + `@mui/material-nextjs` AppRouterCacheProvider (custom dark theme at `src/theme.ts`)
- **`@mui/icons-material`** for icons
- **Geist** fonts wired into the MUI theme
- **NextAuth.js 4** for authentication (email & password, JWT sessions)
- **Zod + react-hook-form** for form validation (shared client/server schemas)
- **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-MUI-Template
cd Christophers-Next-MUI-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/theme.ts` — Centralized MUI theme (dark palette, Geist typography, component overrides)
- `src/app/` — Next.js App Router pages (home, sign-up, sign-in, dashboard, `not-found.tsx`)
- `src/components/` — Reusable UI components (Spinner, 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. `Spinner.tsx` + `Spinner.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 MUI 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`, with MUI's `<Controller>` pattern wrapping `<TextField>`. 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).
## Theming
The MUI theme lives at `src/theme.ts` (dark mode, primary `#20cb91`). Geist Sans is wired in via:
```ts
typography: { fontFamily: 'var(--font-geist-sans)', ... }
```
The font itself is loaded with `next/font/google` in `src/app/layout.tsx`. Without the `src/theme.ts` wiring, MUI components fall back to Roboto regardless of body styles.
## 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/Spinner.test.tsx`
- Tests are co-located next to the components they cover (e.g. `Spinner.tsx` + `Spinner.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 · 启动器
