- 🔐 身份认证 - 邮箱密码 + OAuth(Google、GitHub),基于 Better Auth
- 👥 RBAC 权限系统 - 角色、权限、菜单的完整权限控制
- 📊 后台管理面板 - 配置驱动的 CRUD,SmartCrudPage 开箱即用
- 📝 操作日志 - 全面的审计追踪
- 📁 资源管理 - 支持 Cloudflare R2 的文件上传和管理
- 🌐 国际化 - 基于 next-intl 的多语言支持
- 🎨 现代化 UI - Ant Design + ProComponents
| 类别 | 技术 |
|---|---|
| 框架 | Next.js 16 (App Router) |
| 数据库 | PostgreSQL + Prisma |
| 认证 | Better Auth |
| UI 组件 | Ant Design、ProComponents |
| 样式 | Tailwind CSS |
| 语言 | JavaScript (ES6+) |
- Node.js 20.9+
- PostgreSQL 16+
- bun(推荐)/ pnpm / npm / yarn
# 克隆仓库
git clone https://github.com/huglemon/nextjs-base.git
cd nextjs-base
# 安装依赖
bun install
# 配置环境变量
cp .env.example .env.local
# 安装 Prisma CLI(开发依赖)
bun add -d prisma
bun add @prisma/client
bunx prisma generate
bunx prisma generate --no-engine
# 初始化数据库并创建管理员
bun run init
# 启动开发服务器
bun run dev打开 http://localhost:3000 查看应用。
# 数据库(必填)
DATABASE_URL="postgresql://user:password@localhost:5432/nextjs_base"
# Better Auth(必填)
BETTER_AUTH_SECRET="至少32位的密钥字符串"
BETTER_AUTH_URL="http://localhost:3000"
# OAuth(可选)
GOOGLE_CLIENT_ID=""
GOOGLE_CLIENT_SECRET=""
GITHUB_CLIENT_ID=""
GITHUB_CLIENT_SECRET=""
# Cloudflare R2(可选 - 用于文件上传)
R2_ACCOUNT_ID=""
R2_ACCESS_KEY_ID=""
R2_SECRET_ACCESS_KEY=""
R2_BUCKET_NAME=""
R2_PUBLIC_URL=""nextjs-base/
├── app/
│ ├── (admin)/ # 后台管理
│ │ ├── admin/ # 后台页面
│ │ └── actions/ # Server Actions
│ ├── (client)/ # 前台(支持国际化)
│ │ └── [locale]/ # 语言路由
│ └── api/ # API 路由
├── components/
│ ├── admin/ # 后台组件(SmartCrudPage、SmartForm)
│ └── ui/ # 基础 UI 组件
├── lib/
│ ├── auth/ # 认证
│ ├── core/ # 核心工具(wrapAction、createCrudActions)
│ └── database/ # Prisma 客户端
├── prisma/
│ └── schema.prisma # 数据库模型
└── docs/ # 文档
欢迎贡献代码!请查看我们的贡献指南了解详情。
- Fork 本仓库
- 从
develop分支创建新分支:git checkout -b feature/your-feature - 进行修改
- 向
develop分支提交 Pull Request
本项目基于 MIT 许可证开源 - 查看 LICENSE 文件了解详情。
欢迎加入我们的社区,交流问题、分享经验、获取最新动态!
- Next.js - React 框架
- Prisma - 新一代 ORM
- Better Auth - 认证库
- Ant Design - UI 组件库
