一个现代化、极简的 Next.js 15 启动模板,集成了 Motion 动画、Zustand 状态管理、Tailwind CSS v4 和 TypeScript。生产就绪,内置深色模式、工程化最佳实践和自动部署。
语言: 中文 | English
- 🚀 Next.js 15 - 最新的 React 框架,支持 App Router 和 Turbopack
- 🎨 Tailwind CSS v4 - 新一代原子化 CSS 框架
- 🐻 Zustand - 轻量级、可扩展的状态管理
- 🎭 Motion - 高性能动画库,声明式 API
- 🌗 深色模式 - 无缝主题切换,支持系统偏好
- 📘 TypeScript - 完整类型安全,启用严格模式
- 🛠️ 工程化工具 - ESLint、Prettier、Husky、lint-staged 和 Commitlint
- 🚀 GitHub Actions - 自动部署到 GitHub Pages
- 📦 clsx - 条件类名工具,让组件代码更简洁
这个模板提供极简、生产就绪的基础,而非臃肿的框架。它只包含必需品,让你可以:
- 添加喜欢的 UI 组件库(shadcn/ui、Ant Design、Material-UI 等)
- 集成任何数据库方案(Prisma、Drizzle、Supabase 等)
- 实现身份认证(NextAuth、Clerk、Auth0 等)
- 使用自己的后端架构进行扩展
- Node.js 18+
- pnpm(推荐)或 npm/yarn
# 克隆仓库
git clone https://github.com/crper/next-modern-starter.git
cd next-modern-starter
# 安装依赖
pnpm install
# 使用 Turbopack 启动开发服务器
pnpm dev在浏览器中打开 http://localhost:3000 查看应用。
推送到 main 或 master 分支即可通过 GitHub Actions 自动部署:
- 在仓库设置中启用 GitHub Pages
- 将源设置为 "GitHub Actions"
- 推送代码 - 部署会自动进行
点击上方的 "使用 Vercel 部署" 按钮或执行:
npx vercel此模板适用于任何支持 Next.js 的平台:
- Netlify
- Railway
- Render
- AWS Amplify
├── .github/
│ └── workflows/
│ └── deploy.yml # GitHub Pages 部署配置
├── public/ # 静态资源
│ └── images/ # 优化的图片资源
├── src/
│ ├── app/ # Next.js App Router
│ │ ├── layout.tsx # 根布局与 providers
│ │ ├── page.tsx # 首页
│ │ └── globals.css # 全局样式和 Tailwind
│ ├── components/ # React 组件
│ │ ├── Counter.tsx # 计数器演示(Zustand)
│ │ ├── TodoList.tsx # 待办事项演示(动画)
│ │ ├── ThemeToggle.tsx # 主题切换器
│ │ └── ThemeProvider.tsx # 主题上下文提供者
│ └── store/ # Zustand 状态库
│ └── index.ts # 全局状态管理
├── eslint.config.mjs # ESLint 扁平配置
├── next.config.ts # Next.js 配置
├── tailwind.config.ts # Tailwind CSS v4 配置
└── tsconfig.json # TypeScript 配置
- 通过 CSS
@config指令配置 - 自动深色模式,使用
dark:变体 - 在
globals.css中自定义主题变量 - 性能优化
基于 next-themes 实现:
- 系统偏好检测
- 手动主题切换
- 加载无闪烁
- 持久化选择
- CSS 变量主题
// 条件类名
className={clsx(
'base-class',
{
'active-class': isActive,
'error-class': hasError,
}
)}
// 多条件组合
className={clsx(
'text-sm font-medium',
isLarge && 'text-lg',
color === 'primary' && 'text-blue-600'
)}pnpm dev- 使用 Turbopack 启动开发服务器pnpm build- 构建生产版本pnpm start- 启动生产服务器pnpm lint- 运行 ESLintpnpm type-check- 检查 TypeScript 类型
使用 TypeScript 的 Zustand 状态库:
// 计数器 store 示例
const { count, increment, decrement } = useCounterStore();
// 带持久化的任务 store
const { tasks, addTask, toggleTask } = useTaskStore();特性:
- Redux DevTools 集成
- 持久化中间件
- TypeScript 自动补全
- 最少的样板代码
集成 Motion(Framer Motion):
// 简单动画
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.5 }}
>
内容
</motion.div>
// 使用 AnimatePresence
<AnimatePresence mode="wait">
{items.map(item => (
<motion.div key={item.id} exit={{ opacity: 0 }}>
{item.content}
</motion.div>
))}
</AnimatePresence>遵循 约定式提交:
feat:新功能fix:修复问题docs:文档更新style:代码风格变化refactor:代码重构test:测试更新chore:维护任务
- ESLint 配合 Next.js 推荐规则
- Prettier 保持一致的格式
- Husky 实现预提交钩子
- TypeScript 严格模式
- Fork 这个仓库
- 创建你的功能分支 (
git checkout -b feature/amazing-feature) - 提交你的更改 (
git commit -m 'feat: 添加神奇功能') - 推送到分支 (
git push origin feature/amazing-feature) - 打开一个 Pull Request
MIT 许可证 - 查看 LICENSE 文件了解详情。
- Next.js - React 框架
- Motion - 动画库
- Zustand - 状态管理
- Tailwind CSS - CSS 框架
- next-themes - 主题管理
编码愉快! 🎉