Next.jsReact启动器

Christophers-Next-Template — Next.js 启动器模板

作者 christopherrobin

一个带邮箱密码认证、Postgres 数据层与完整测试分层的 Next.js 启动器,采用 MIT 许可,适合作为全栈应用的初始骨架。

看看你的网站会是什么样

浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。

2 个预览视图
桌面端首页1 / 2
桌面端截图首屏预览

由服务器浏览器实际访问页面后截取。

全部页面与视图 2

截图用于了解视觉与布局,交互效果请以实际项目为准。

采集于 2026-10-06查看来源

值得关注的模板亮点

从已有项目资料中,快速了解它的特点。

01

集成 NextAuth.js 邮箱密码认证与 JWT 会话,附带注册、登录和受保护仪表盘页面

02

使用 Prisma 连接 PostgreSQL,包含 schema 与迁移文件

03

通过 Zod 与 react-hook-form 在客户端和服务端共享表单校验规则

04

包含 Jest + Testing Library 单元/组件测试与 Playwright 端到端测试

05

配置 ESLint、Prettier 与 Next 16 的 proxy 中间件做路由保护

06

采用 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.jsReact启动器

适合你的项目吗?

适用场景

  • 需要快速搭建带邮箱密码认证的全栈 Next.js 应用原型
  • 希望以 Prisma + PostgreSQL 作为数据层起步的项目
  • 需要同时具备单元测试和端到端测试配置的初始工程
  • 想参考 Next.js App Router 下中间件路由保护与表单校验的组织方式

适合人群

  • 熟悉 Next.js、TypeScript 和 Prisma 的开发者
  • 需要可扩展认证骨架的全栈项目
  • 希望自带测试分层与代码规范配置的团队
  • 能自行准备 PostgreSQL 数据库和托管环境的用户

上手与定制指南

结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。

  1. 1

    需要 Node.js 24+,仓库提供 .nvmrc 可运行 nvm use

  2. 2

    需要准备 PostgreSQL 数据库连接

  3. 3

    复制 .env.local.example 为 .env.local,填写 DATABASE_PUBLIC_URL、NEXTAUTH_SECRET 和 NEXTAUTH_URL

  4. 4

    使用 yarn install 安装依赖,yarn prisma migrate deploy 执行迁移,yarn dev 启动开发服务器

  5. 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 原文

3. Configure environment variables: - Copy `.env.local.example` to `.env.local` and fill in your database and secret values.

README 原文
https://github.com/christopherrobin/Christophers-Next-Template/blob/main/LICENSEhttps://github.com/christopherrobin/Christophers-Next-Template/blob/main/README.md

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

[![CI](https://github.com/christopherrobin/Christophers-Next-Template/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/christopherrobin/Christophers-Next-Template/actions/workflows/ci.yml)
[![Tested with Jest](https://img.shields.io/badge/tested_with-jest-99425B?style=flat-square&logo=jest&logoColor=white)](https://jestjs.io/)
[![E2E with Playwright](https://img.shields.io/badge/e2e_with-playwright-2E7D32?style=flat-square&logo=playwright&logoColor=white)](https://playwright.dev/)
[![Coverage](https://img.shields.io/badge/coverage-90%25_threshold-informational?style=flat-square)](https://github.com/christopherrobin/Christophers-Next-Template/blob/main/jest.config.ts)
[![ESLint](https://img.shields.io/badge/eslint-flat_config-4B32C3?style=flat-square&logo=eslint&logoColor=white)](https://github.com/christopherrobin/Christophers-Next-Template/blob/main/eslint.config.mjs)
[![Prettier](https://img.shields.io/badge/code_style-prettier-F7B93E?style=flat-square&logo=prettier&logoColor=black)](https://github.com/christopherrobin/Christophers-Next-Template/blob/main/.prettierrc)

[![Next.js](https://img.shields.io/badge/Next.js-16-000000?style=for-the-badge&logo=nextdotjs&logoColor=white)](https://nextjs.org/)
[![React](https://img.shields.io/badge/React-19-61DAFB?style=for-the-badge&logo=react&logoColor=black)](https://react.dev/)
[![TypeScript](https://img.shields.io/badge/TypeScript-strict-3178C6?style=for-the-badge&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
[![Tailwind CSS](https://img.shields.io/badge/Tailwind_CSS-4-06B6D4?style=for-the-badge&logo=tailwindcss&logoColor=white)](https://tailwindcss.com/)
[![Prisma](https://img.shields.io/badge/Prisma-7-2D3748?style=for-the-badge&logo=prisma&logoColor=white)](https://www.prisma.io/)
[![PostgreSQL](https://img.shields.io/badge/PostgreSQL-4169E1?style=for-the-badge&logo=postgresql&logoColor=white)](https://www.postgresql.org/)
[![NextAuth.js](https://img.shields.io/badge/NextAuth.js-4-000000?style=for-the-badge&logo=auth0&logoColor=white)](https://next-auth.js.org/)

![Welcome Preview](public/welcome.png)

## 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).
反馈内容错误

看看同类模板

对比同技术栈与用途的模板,找到更适合的视觉与内容结构。