使用 Next.js App Router,并把路由分为 (auth) 私有路由与 (unauth) 公开路由两组
nextjs-boilerplate — Next.js 启动器模板
作者 nhanluongoe
基于 Next.js App Router 的启动器模板,内置 TypeScript、TailwindCSS、NextAuth 与 ESLint/Prettier/Husky 等工程化配置,并提供按认证与公开路由分组的可扩展目录结构。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
提供可扩展的目录结构:项目级共享内容放在 src,app 下按领域/功能组织组件、类型、hooks 与 route handler
components/ui 存放 Button、Tag 等原子组件,Header、Footer 等组合组件置于其外
集成 NextAuth,示例以 GitHub 为登录提供方
内置 ESLint 9、Prettier、Husky、lint-staged 与 Commitlint,提交前检查暂存文件并要求 conventional commits 提交信息
包含 robots.ts 与 sitemap.ts,生成 robots.txt 与 sitemap.xml,并支持 @ 别名绝对导入
模板详细介绍
这是一个面向 Next.js 项目的启动器模板,目标是在新建项目时省去重复的初始配置。它使用 App Router,并把路由划分为 (auth) 与 (unauth) 两个分组:前者放置需要登录的页面(示例为 profile),后者放置公开页面(示例为首页与 products)。
目录组织上,项目级共享内容放在 src 下,包括 components、types、styles、utils 与 api;其中 components/ui 存放 Button、Tag 这类原子组件,Header、Footer 等组合组件放在 ui 之外。app 目录按领域/功能组织,每个功能可自带 components、types、hooks 与 route handler。模板还提供 @ 别名绝对导入,以及 robots.ts 与 sitemap.ts 生成 robots.txt 和 sitemap.xml。
认证部分集成 NextAuth,示例使用 GitHub 作为登录提供方,需要自行创建 GitHub OAuth 应用并配置 AUTH_SECRET、AUTH_GITHUB_ID、AUTH_GITHUB_SECRET 环境变量后才能正常运行。工程规范方面,ESLint 9 配合 eslint-config-next 与 typescript-eslint,Prettier 负责格式化,Husky 与 lint-staged 在提交前对暂存文件执行检查,Commitlint 要求提交信息遵循 conventional commits。
使用方式为克隆仓库或点击 Use this template 生成新仓库,安装依赖后运行开发命令。模板以 MIT 许可发布,可免费使用、修改、商用与分发,但需保留版权与许可声明;演示中的图片、字体、图标等第三方素材以及托管、数据库等外部服务需另行核对许可与费用。
适合你的项目吗?
适用场景
- 需要快速搭建一个带登录与公开页面分组的 Next.js 新项目
- 希望新项目一开始就有统一的目录约定与组件分层方式
- 需要为团队项目预置代码检查、格式化与提交信息规范
- 需要为 Next.js 项目配置基于 GitHub 的登录入口
- 需要为站点准备 robots.txt、sitemap.xml 与基础 SEO 元信息结构
适合人群
- 准备从零开始一个 Next.js 应用并希望减少初始配置工作的开发者
- 接受 App Router 与按领域组织目录的团队项目
- 需要 TypeScript、TailwindCSS 与 ESLint/Prettier 等基础工具链的项目
- 计划使用 NextAuth 并自行配置 OAuth 提供方的项目
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
克隆仓库或点击 Use this template 创建新仓库,然后执行 npm install 与 npm run dev
- 2
运行前需配置 NextAuth:创建 GitHub OAuth 应用,并在 .env 中设置 AUTH_SECRET、AUTH_GITHUB_ID、AUTH_GITHUB_SECRET
- 3
提交信息需遵循 conventional commits,否则会被 Commitlint 拦截
- 4
模板以 MIT 许可发布,分发代码副本或实质性部分时需保留原作者版权声明与完整 MIT 许可声明
- 5
演示图片、字体、图标等第三方素材以及域名、托管、数据库等外部服务需自行核对许可与费用
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 使用前必须自行配置 NextAuth:需创建 GitHub OAuth 应用,并在 .env 中设置认证相关环境变量(AUTH_SECRET、AUTH_GITHUB_ID、AUTH_GITHUB_SECRET),否则项目无法正常运行;这依赖外部 GitHub 服务与账号。
- 提交信息必须遵循 conventional commits 规范,否则会被 Commitlint 拦截,属于项目约定的使用限制。
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
Make sure you config your NextAuth before running the project. For this boilerplate, it uses Github as the authentication provider so you need to create a Github OAuth app and set the `GITHUB_ID` and `GITHUB_SECRET` environment variables in your `.env` file.
README 原文
https://github.com/nhanluongoe/nextjs-boilerplate/blob/main/LICENSEhttps://github.com/nhanluongoe/nextjs-boilerplate/blob/main/README.mdCommit messages must follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/).
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-03。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 92 / 100
- 技术栈
- Next.js · React
- 网站类型
- 启动器
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-08-12
- 截图检查日期
- 2026-10-03
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
已完成服务器许可规则与 AI 来源核对;未经过人工编辑审核。
查看当时使用的来源资料
SHA-256: 219a2fee33f1ef750ffffada9e356c0f6e58190ef8ece179b1fee24cc51d1767
2026-10-03T00:39:17.303Z
来源文件 / 仓库# Next.js Boilerplate and Starter-Kit. Minimal yet scalable setup for Next.js projects A Next.js 16 boilerplate that helps you jump right into building your app without having to set up everything from scratch every time you start a new project. It comes with a minimal yet scalable setup that includes Next.js 16 with Turbopack, React 19, TypeScript, TailwindCSS, ESLint 9, Prettier, Husky, Lint-staged, Commitlint, and SEO-friendly features. ## Live Demo Check out the live demo of this boilerplate in action: [https://nextjs-boilerplate-oe.vercel.app](https://nextjs-boilerplate-oe.vercel.app) ## Features - [x] [Next.js 16](https://nextjs.org): Full-fledged framework for React apps with Turbopack - [x] [Typescript](https://typescriptlang.org): Type checking and better code quality - [x] [TailwindCSS](https://tailwindcss.com/): Utility-first CSS framework - [x] [ESLint 9](https://eslint.org): Modern pluggable linting utility for JavaScript - [x] [Prettier](https://prettier.io): Opinionated code formatter - [x] [Husky](https://typicode.github.io/husky): Git hooks made easy - [x] [Lint-staged](https://github.com/lint-staged/lint-staged): Run linters on git staged files - [x] [Commitlint](https://commitlint.js.org/): Lint commit messages - [x] [NextAuth](https://authjs.dev/): Powerful authentication for Next.js - [x] SEO-friendly: Meta tags, Open Graph, sitemap.xml and robots.txt - [x] Absolute imports: Import directories and files using the @ alias - [x] Route grouping: Group routes for auth and public pages ## Use this boilerplate You can either clone this repository using command line or clicking on the "Use this template" button to create a new repository with the same directory structure. ```sh git clone --depth=1 https://github.com/nhanluongoe/nextjs-boilerplate.git project-name cd project-name npm install npm run dev ``` Make sure you config your NextAuth before running the project. For this boilerplate, it uses Github as the authentication provider so you need to create a Github OAuth app and set the `GITHUB_ID` and `GITHUB_SECRET` environment variables in your `.env` file. You can find more information about how to do this in the [NextAuth documentation](https://authjs.dev/guides/configuring-github). Basically your .env file should look like this: ```env AUTH_SECRET="yourAuthSecret" AUTH_GITHUB_ID=yourGithubClientId AUTH_GITHUB_SECRET=yourGithubClientSecret ``` ## Project Structure - All common things (project-wide, global) are placed in the `src` directory. This includes components, types, styles, and utility functions. This is where we put things that are shared across the project. - In the project wide components, we have `ui` directory that contains atomic design components like `Button`, `Tag`. Outside of the `ui` directory, there are components composed of atomic components like `Header`, `Footer`. - In the `app` directory we have domains/features. This includes components, types, hooks, api (route handler) ... that are only used in that domain/feature. Basically these directories include things similar to the global things but are only used in the domain/feature. - The project uses Next.js App Router to handle routing. The router is divided into two groups: `auth` and `unauth`. The `auth` group contains routes that require authentication, while the `unauth` group contains public routes. ``` |-- public # Static files |-- src # Next.js source directory | |-- app # Next.js App Router | | |-- (auth) # (Group) Private routes | | | |-- layout.tsx # Authenticated layout | | | |-- profile # (Module) Profile page | | | | `-- page.tsx | | |-- (unauth) # (Group) Public routes | | | |-- layout.tsx # Unauthenticated layout | | | |-- page.tsx # Unauthenticated index page | | | `-- products # (Module) Product page | | | |-- components # Components for the product page | | | | `-- ProductCard.tsx | | | |-- layout.tsx | | | `-- page.tsx | | |-- layout.tsx # App layout | | |-- robots.ts # Robots.txt | | `-- sitemap.ts # Sitemap.xml | |-- components # Global components | | |-- Footer.tsx | | |-- Header.tsx | | `-- ui # Atomic design components | | |-- Button.tsx | | `-- Tag.tsx | |-- api # Global API route handlers | | `-- auth | |-- styles | | `-- global.css # Global styles | |-- types # Global types | | `-- global.ts | |-- libs # 3rd-party libraries | | `-- auth.ts | `-- utils # Global utility functions | `-- helpers.ts |-- tailwind.config.ts # TailwindCSS configuration |-- .eslintrc.json # ESLint configuration |-- .prettierrc # Prettier configuration |-- LICENSE |-- README.md |-- commitlint.config.ts # Commitlint configuration |-- lint-staged.config.js # Lint-staged configuration |-- next-env.d.ts |-- next.config.mjs |-- package-lock.json |-- package.json |-- postcss.config.mjs # PostCSS configuration `-- tsconfig.json # Typescript configuration ``` ## Commit message convention - The project uses Husky and Lint-staged to run ESLint and Prettier on staged files before committing. - Commit messages must follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). ## Eslint configuration - The project uses modern ESLint 9 configuration compatible with Next.js 16. The configuration is based on the following packages: - [eslint-config-next](https://www.npmjs.com/package/eslint-config-next): Next.js ESLint configuration. - [typescript-eslint v8](https://typescript-eslint.io/): Enables ESLint to lint TypeScript code. ## Contributing If you have a question or have found a bug, or have any suggestions for improvement, feel free to create an issue or a pull request. Everyone is welcome. ## License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

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