内置邮箱与 Microsoft SSO 认证,含 OAuth 回调与开发环境魔法链接登录
nextjs-supabase-starter — Next.js 启动器模板
作者 levyan76
基于 Next.js 16 与 Supabase 的全栈起始模板,README 说明其内置认证、RLS 角色权限、i18n、限流、功能开关、测试、CI 与 Docker 配置。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
通过 RLS 与 JWT app_metadata 实现基于角色的访问控制,README 称客户端不可伪造
使用 next-intl 提供 FR/EN 路由与语言切换,包含通用翻译键
滑动窗口限流,支持内存回退并可接入 Upstash
包含 67 个 Vitest 单元测试与 Playwright E2E 测试,以及 GitHub Actions CI 流程
提供多阶段 Docker 构建、非 root 用户与 standalone 输出配置
模板详细介绍
该模板面向需要快速搭建带后台的 Next.js + Supabase 应用的开发者。README 描述其包含邮箱与 Microsoft SSO 登录、基于 RLS 与 JWT app_metadata 的角色权限、FR/EN 的 next-intl 路由、滑动窗口限流、结构化日志、数据库驱动的功能开关,以及 67 个 Vitest 单元测试和 Playwright E2E 测试。项目还提供 GitHub Actions CI、多阶段 Docker 构建、Husky 与 lint-staged 预提交钩子、Dependabot 配置和安全响应头。
README 给出的快速开始步骤包括:克隆仓库、复制 .env.local.example 并填写 Supabase URL 与密钥、执行 npm install、用 npx supabase start 与 db reset 启动本地 Supabase 并应用迁移和种子数据、运行 npm run dev,最后访问 /setup 创建首个管理员。也可使用 scripts 下的 new-app 脚本复制模板。
README 未说明该模板的实际运行性能、生产环境部署细节或除 Supabase 外的后端集成方式,这些内容需以仓库实际代码为准。
适合你的项目吗?
适用场景
- 需要快速启动带认证与角色权限的 Next.js + Supabase 后台应用
- 希望以 FR/EN 双语路由作为起点搭建多语言站点
- 需要在项目中直接使用限流、结构化日志和数据库功能开关等基础设施
- 希望参考包含单元测试、E2E 测试和 CI 配置的全栈项目结构
适合人群
- 熟悉 Next.js App Router 与 Supabase 的开发者
- 需要可自定义的认证与权限起始代码的团队
- 希望以 Docker 和 CI 流程作为项目起点的工程团队
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
克隆仓库后复制 .env.local.example 为 .env.local,至少填写 NEXT_PUBLIC_APP_NAME 与 Supabase URL 和密钥
- 2
执行 npm install 安装依赖
- 3
本地运行 Supabase 需要 Docker,使用 npx supabase start 与 npx supabase db reset 应用迁移和种子数据
- 4
运行 npm run dev 启动开发服务器,默认端口 3000
- 5
首次访问 /setup 创建管理员,该端点仅在首个管理员创建前可用
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
- 本地运行 Supabase 需要 Docker 环境,未安装 Docker 时无法按 README 步骤启动本地数据库。
- 使用前必须配置 .env.local,至少填写 NEXT_PUBLIC_APP_NAME 以及 Supabase URL 和密钥。
- 认证功能包含 Microsoft SSO,使用该登录方式需依赖 Microsoft 的 OAuth 服务。
- 限流默认使用内存回退,生产环境接入 Upstash 需额外配置外部服务。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
# 4. Start Supabase locally (requires Docker)
README 原文
# Edit .env.local — at minimum: NEXT_PUBLIC_APP_NAME, Supabase URL + keys
README 原文
| 🔐 Auth (email + Microsoft SSO) | + OAuth callback, magic link logging in dev |
README 原文
https://github.com/levyan76/nextjs-supabase-starter/blob/main/LICENSEhttps://github.com/levyan76/nextjs-supabase-starter/blob/main/README.md| 🚦 Rate limiting | Sliding window, in-memory fallback, Upstash-ready |
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-14。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 85 / 100
- 技术栈
- Next.js · React
- 网站类型
- 启动器
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-07-20
- 截图检查日期
- 2026-10-14
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
审核声明: codex-user-requested-batch-review-20261015 · 2026-10-15
查看当时使用的来源资料
SHA-256: 05250ec3389cb780d3ca6dcf501d1805af573c313bb6b547226fb7a6d3b08b1f
2026-10-14T20:27:14.512Z
来源文件 / 仓库<div align="center">
# nextjs-supabase-starter
**Production-grade Next.js 16 + Supabase starter** — auth, RLS, i18n, rate limiting, feature flags, tests, CI, Docker. Ready to ship.
[](https://github.com/levyan76/nextjs-supabase-starter/actions/workflows/ci.yml)
[](LICENSE)
[](https://nextjs.org)
[](https://react.dev)
[](https://supabase.com)
[](https://www.typescriptlang.org)
[](https://tailwindcss.com)
[English](./README.md) · [Français](./README.fr.md)
</div>
---
## Why this starter
Most "Next.js + Supabase" boilerplates give you auth and stop there. This one ships with the boring-but-critical plumbing every real app needs — so you can focus on what makes yours different.
| You get on day 1 | Without writing it yourself |
| ------------------------------- | -------------------------------------------------------- |
| 🔐 Auth (email + Microsoft SSO) | + OAuth callback, magic link logging in dev |
| 👮 Role-based access | RLS + JWT `app_metadata`, non-spoofable client-side |
| 🌍 i18n routing (FR/EN) | `next-intl`, locale switcher, all generic keys included |
| 🚦 Rate limiting | Sliding window, in-memory fallback, Upstash-ready |
| 📊 Structured logging | JSON in prod, colored in dev, named events |
| 🚩 Feature flags | DB-backed, React hook, no redeploy needed |
| 🧪 67 unit tests + E2E | Vitest + Playwright, all green |
| 🛡️ Security headers | CSP env-aware, HSTS, X-Frame-Options, Permissions-Policy |
| 🤖 CI/CD | GitHub Actions: lint + typecheck + test + build + E2E |
| 📦 Docker | Multi-stage, non-root user, standalone output |
| 🧹 Pre-commit hooks | Husky + lint-staged (eslint --fix + prettier) |
| 📈 Dependabot | Weekly grouped bumps, ignore Next/React majors |
---
## Quick start
```bash
# 1. Clone
git clone https://github.com/levyan76/nextjs-supabase-starter.git my-app
cd my-app
rm -rf .git && git init -b main
# 2. Configure
cp .env.local.example .env.local
# Edit .env.local — at minimum: NEXT_PUBLIC_APP_NAME, Supabase URL + keys
# 3. Install
npm install
# 4. Start Supabase locally (requires Docker)
npx supabase start
npx supabase db reset # applies migrations + seed
# 5. Run
npm run dev # → http://localhost:3000
# 6. Set up the first admin
# Visit http://localhost:3000/setup
```
### Or use the scaffold script
```powershell
# Windows
.\scripts\new-app.ps1 -AppName "my-app" -Port 3001
```
```bash
# Linux / macOS
./scripts/new-app.sh my-app 3001
```
The script copies the template into a sibling folder, renames `package.json`, configures the port, fills `.env.local`, and creates a clean git init.
---
## Architecture
```
app/ # Next.js App Router
├── [locale]/
│ ├── (auth)/ # login, callback, setup
│ └── (dashboard)/ # admin/, client/, profile/, settings/
└── api/setup/route.ts # First-admin creation endpoint
components/
├── dashboard/ # layout, header, sidebar
└── ui/ # 32 shadcn/ui components
lib/
├── auth/roles.ts # ROLES, PERMISSIONS, isAdmin, canAccess
├── server/
│ ├── auth.ts # requireUser, requireAdminRole
│ ├── action-response.ts # ActionResponse<T>, withActionResponse
│ ├── rate-limit.ts # Sliding window (memory or Upstash)
│ ├── logger.ts # Structured JSON / colored dev logs
│ └── feature-flags.ts # isEnabled(key)
├── supabase/{client,server,types}.ts
├── i18n/{routing,request}.ts
├── pdf/ # @react-pdf/renderer document base
└── validations/ # zod schemas
middleware.ts # Rate limit → i18n → auth → admin guard
supabase/
├── migrations/ # 5 migrations (profiles, audit, flags, JWT refresh)
└── seed.sql # Dev users + flags
tests/
├── unit/ # 67 Vitest tests
└── e2e/ # Playwright (auth + home)
```
---
## Stack
| Layer | Choice |
| ------------- | -------------------------------------------------- |
| Framework | Next.js 16 (App Router, Server Actions) |
| Runtime | React 19.2 |
| Styles | Tailwind 4 + shadcn/ui + `tw-animate-css` |
| UI primitives | Radix UI (individual `@radix-ui/react-*` packages) |
| Auth + DB | Supabase (`@supabase/ssr` + `supabase-js`) |
| i18n | next-intl 4 (FR/EN) |
| Forms | react-hook-form 7 + zod 4 |
| Data | TanStack Query 5 |
| PDF | @react-pdf/renderer 4 |
| Charts | recharts 3 |
| Drag & drop | @dnd-kit |
| Canvas | Konva 10 |
| CSV | papaparse + json2csv |
| Tests | Vitest 4 + Playwright 1.60 |
| Lint / Format | ESLint 9 + Prettier 3 |
| Container | Docker multi-stage (node 22-alpine) |
---
## Security
| Control | Status |
| ---------------------------------------------------------- | ----------------- |
| RLS on all tables | ✅ |
| JWT `role` synced server-side via Postgres trigger | ✅ non-spoofable |
| `.env.local` git-ignored | ✅ |
| Service-role key server-only | ✅ |
| CSP env-aware | ✅ strict in prod |
| HSTS, X-Frame-Options, Referrer-Policy, Permissions-Policy | ✅ |
| Rate limiting per IP + per route | ✅ |
| Open redirect prevention (`?redirect=`) | ✅ |
| Password policy (min 8, upper, digit, special) | ✅ |
| `/setup` idempotent (blocked after first admin) | ✅ |
If you find a vulnerability, please email [[email protected]](mailto:[email protected]) — don't open a public issue.
---
## Scripts
```bash
npm run dev # dev server on port 3000
npm run build # production build
npm run typecheck # tsc --noEmit
npm run lint # eslint .
npm run format # prettier --write
npm test # Vitest (one-shot)
npm run test:watch # Vitest watch mode
npm run test:coverage # HTML coverage report
npm run test:e2e # Playwright (headless)
npm run test:e2e:ui # Playwright UI mode
npm run generate:schema # regen Supabase types
npm run supabase:reset # reapply migrations + seed
```
---
## Customizing for your app
1. **Brand** → `.env.local`: `NEXT_PUBLIC_APP_NAME`, `NEXT_PUBLIC_LOGO_PATH`, `NEXT_PUBLIC_BRAND_PRIMARY`
2. **Domain tables** → new migration `supabase/migrations/000XX_<feature>.sql`
3. **Navigation** → add items in `components/dashboard/sidebar/sidebar.tsx`
4. **Pages** → new routes under `app/[locale]/(dashboard)/`
5. **Server actions** → use the `withActionResponse()` pattern from `lib/server/action-response.ts`
6. **Feature flags** → `INSERT INTO feature_flags (key, enabled, description) VALUES (...)`
7. **i18n** → add keys to `messages/en.json` and `messages/fr.json`
8. **Roles** → extend `PERMISSIONS` in `lib/auth/roles.ts`
---
## Contributing
See [CONTRIBUTING.md](./CONTRIBUTING.md) — short workflow + standards.
## License
MIT © Yan Levasseur. See [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 · 启动器
