集中式四角色 RBAC(Owner/Admin/Member/Viewer),服务端强制成员校验
saas-starter-kit — Next.js SaaS模板
作者 shipap
基于 Next.js 的多租户 SaaS 启动器,内置 RBAC、团队与工作区、模拟计费、API 密钥、审计日志和隔离演示沙箱。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
组织创建、切换与设置,支持团队邀请、角色管理和开发邮件 outbox
工作区 API 密钥:一次性明文展示、哈希存储、作用域与撤销
模拟计费支持 Free/Pro/Business 计划状态切换,预留 Stripe 适配器边界
隔离演示沙箱:每位访客独立数据,六小时过期,重置仅影响自身
本地使用 PGlite 进程内 PostgreSQL,生产使用 pg 连接 PostgreSQL,共用初始 schema
模板详细介绍
这是一个多租户 SaaS 基础模板,围绕虚构的 B2B 工作区控制台 Relay 演示账号、工作区、团队权限、计费状态和 API 访问等基础能力。仓库采用 Next.js,代码分为 apps/web(产品界面与 API 桥接)和 packages/platform、db、auth、billing、email、shared 等包,业务操作集中在 platform 包中。
权限方面提供集中式四角色模型(Owner/Admin/Member/Viewer),组织级读取与写入都要求服务端成员校验,客户端传入的资源 ID 或组织 ID 不作为授权依据。API 密钥按租户作用域鉴权,明文仅在创建时展示一次,存储时使用哈希并支持撤销与作用域。
计费为模拟实现,可安全切换 Free、Pro、Business 计划状态,并预留 Stripe 适配器边界;邀请令牌一次性使用且有过期时间,邮件停留在开发用 outbox 中。本地开发使用 PGlite 在进程内运行 PostgreSQL,无需 Docker;生产驱动使用 pg 连接 PostgreSQL,两者共用同一套初始 schema。
公开演示为每位访客分配独立沙箱,数据为虚构内容,六小时后过期,重置只影响当前沙箱,正常注册在公开演示中关闭。模板定位是可复用的产品基础,而非完整的行业 SaaS:仅包含一种资源类型,商业计划配额为示意性内容,限流按进程实现,所有权转移、真实支付结账、外部邮件投递和版本化 schema 升级仍属待扩展点。
适合你的项目吗?
适用场景
- 需要多租户账号、工作区与团队权限基础的产品原型
- 希望演示 RBAC、API 密钥和审计日志等 SaaS 基础能力的场景
- 在无 Docker、无外部凭据条件下本地运行并体验完整流程
- 作为后续接入真实支付、邮件与业务功能的代码起点
适合人群
- 需要多租户 SaaS 基础骨架的开发团队
- 希望研究服务端权限校验与 API 密钥设计的开发者
- 需要可公开演示且带隔离沙箱的模板使用者
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
本地演示需要 Node.js 24 LTS 与 pnpm 12.8.1,执行 pnpm install 后运行 pnpm demo,访问 http://localhost:3000 选择 Try demo
- 2
生产环境需要独立生成的 BETTER_AUTH_SECRET、PostgreSQL 连接串和精确的 HTTPS 应用源地址
- 3
真实邮件投递需通过 createPlatform({ emailProvider }) 注入;未配置时生产邀请不会发送
- 4
Playwright 浏览器测试需先执行 pnpm exec playwright install chromium
- 5
Docker/Compose 部署需生成独立的 POSTGRES_PASSWORD 与 BETTER_AUTH_SECRET,并设置精确的 HTTPS APP_URL
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 计费为模拟实现,邮件仅停留在开发用 outbox,不会发送真实付款或消息;真实支付与邮件投递需自行接入。
- 生产环境结账、价格/客户映射及乱序事件处理仍需自行集成,Stripe 实际调用未经测试。
- 真实邮件投递需通过 createPlatform({ emailProvider }) 注入;未配置时生产环境邀请将拒绝发送。
- 生产部署需自行生成稳定的 BETTER_AUTH_SECRET、PostgreSQL 连接串及精确的 HTTPS 应用源地址。
- 限流按进程实现,多实例部署需自行提供共享存储。
- 所有权转移、支付结账、外部邮件投递和版本化 schema 升级均为待扩展点,需自行实现。
- OAuth、邮件与 Stripe 的实际线上调用均未经测试。
- 公开演示使用隔离的临时沙箱,不能作为生产客户服务使用。
- 商业计划配额仅为示意,并非强制执行的配额。
- PGlite 为单进程开发数据库,不能替代生产多进程部署。
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
Billing is simulated and email stays in a development outbox; no real payments or messages are sent.
README 原文
Production checkout, price/customer mapping and handling out-of-order provider events still need integration. Live Stripe calls were not tested.
README 原文
Real email delivery is injected through `createPlatform({ emailProvider })`; normal production invitations refuse to send without it.
README 原文
Production requires a stable, independently generated `BETTER_AUTH_SECRET`, PostgreSQL URL and exact HTTPS application origin.
README 原文
Rate limiting is per process and needs a shared store for multiple instances.
README 原文
Ownership transfer, provider checkout, external email delivery and versioned schema upgrades remain extension points.
README 原文
Live OAuth, email and Stripe were not tested.
README 原文
The public demonstration uses isolated temporary sandboxes; it is not a production customer service.
README 原文
Commercial plan entitlements are illustrative, not enforced quotas.
README 原文
https://github.com/shipap/saas-starter-kit/blob/main/LICENSEhttps://github.com/shipap/saas-starter-kit/blob/main/README.mdPGlite is a single-process development database, not a production multi-worker replacement.
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-02。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 88 / 100
- 技术栈
- Next.js · React
- 网站类型
- SaaS · 启动器
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-10-01
- 截图检查日期
- 2026-10-02
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
已完成服务器许可规则与 AI 来源核对;未经过人工编辑审核。
查看当时使用的来源资料
SHA-256: 093a1e05c5d5f77b807d6695dee4ae36d5f0d9c9e22eca2d513cd1d51c7d495c
2026-10-02T13:59:35.146Z
来源文件 / 仓库# SaaS Starter Kit
Build a multi-tenant SaaS product without starting again with accounts, workspaces, team permissions, billing state and API access.
The starter demonstrates those foundations through **Relay**, a fictional B2B workspace console. Open the demo without a password, create projects, invite a teammate through a development outbox, switch roles, try mock plans and issue a real workspace API key. Every demo visitor gets an isolated sandbox. The next step for a client is adding their business-specific feature to this foundation.
Relay and its seeded people, organizations and activity are fictional. Billing is simulated and email stays in a development outbox; no real payments or messages are sent.
## Live Demo
Try it without installing anything: **https://saas.rkn.fail**.
No account required. Each visitor receives an isolated demo sandbox with fictional data. Demo data expires after six hours; reset affects only your sandbox. Normal sign-up is disabled on the public demonstration.
[Try the live demo →](https://saas.rkn.fail)
## Local demo
Requires Node.js 24 LTS and pnpm 12.8.1. From this directory:
```sh
pnpm install
pnpm demo
```
Open **http://localhost:3000** and choose **Try demo**. No Docker, external credentials, real payments or outgoing email are needed. The startup command prepares local database configuration and starts the application on loopback. Initialization applies the schema; each new sandbox is seeded independently. Use **Demo controls** to switch Owner/Admin/Member/Viewer, reset the sandbox or open the development outbox.
## Demo behavior
Each visitor receives a separate sandbox containing fictional workspaces, members, projects and activity. Sessions expire after **six hours**. Reset restores only the current visitor's seeded data. Role switching affects that sandbox's effective role; it never grants normal account or global administrator privileges. The platform preview shows only the caller's sandbox.
Billing is simulated and invitations stay in the guarded development outbox. Demo API keys authenticate requests to this application only. No external service, payment provider or email account is connected.
## Features
- Better Auth email/password sessions and optional configured OAuth providers, separate from demo sessions.
- Organization creation, switching and settings with membership checks on the server.
- Centralized four-role authorization and protected ownership operations.
- Projects with search, status filtering, create/edit/archive and permission-aware controls.
- Expiring, one-use team invitations, role management and a development email outbox.
- Free, Pro and Business plan state through mock billing; a Stripe adapter boundary for later integration.
- Workspace API keys, one-time plaintext reveal, hashes at rest, revocation and scopes.
- API usage records, scoped audit events and meaningful dashboard totals.
- Account preferences, light/dark/system themes and a guarded platform administration preview.
- Isolated demo sandboxes with expiration and scoped reset; no shared destructive reset.
## Screenshots
Real screenshots from the PostgreSQL-backed public demonstration:

<details>
<summary>Live landing and mobile overview</summary>


</details>
<details>
<summary>Additional local screenshots: landing, themes, billing and team</summary>





</details>
## Architecture
```mermaid
flowchart LR
Browser[Relay web interface] --> Next[Next.js API bridge]
Next --> Auth[Better Auth or isolated demo session]
Auth --> Policy[Membership and centralized RBAC]
Policy --> Services[Workspace business services]
Services --> Database[Parameterized SQL and Drizzle auth schema]
Database --> Local[PGlite for local review]
Database --> PG[PostgreSQL for production]
Services --> Outbox[Development email outbox]
Services --> Billing[Mock billing / Stripe adapter]
Key[Workspace API key] --> API[Scoped example API]
API --> Policy
```
`apps/web` contains the product interface and a thin API bridge. `packages/platform` owns business operations. `packages/db`, `auth`, `billing`, `email` and `shared` contain the persistence/auth/provider boundaries and shared data contracts. Tests live in `tests`; startup tooling lives in `scripts`. The repository is self-contained; it includes no adjacent projects or their dependencies.
Design direction and research: [Design brief](docs/DESIGN_BRIEF.md). Server/API contracts: [Implementation contracts](docs/CONTRACTS.md). Self-hosted fonts retain their [Manrope license](docs/licenses/Manrope-OFL.txt) and [DM Sans license](docs/licenses/DM-Sans-OFL.txt).
## RBAC matrix
| Capability | Owner | Admin | Member | Viewer |
| --------------------------------------- | -------------- | ----- | ------ | ------ |
| Read projects, team and audit | Yes | Yes | Yes | Yes |
| Create/edit/archive projects | Yes | Yes | Yes | No |
| Manage invites and non-owner members | Yes | Yes | No | No |
| Manage API keys and workspace settings | Yes | Yes | No | No |
| Change billing plan/state | Yes | No | No | No |
| Delete organization / ownership actions | Yes, protected | No | No | No |
Workspace Admin is not Platform Admin. Hiding or disabling controls is only presentation: server checks are mandatory for every operation. Owner removal, demotion and leaving are blocked; ownership transfer needs a separate explicit workflow. Demo role switching is available only inside a demo sandbox and does not grant access to normal organizations.
## Multi-tenancy and database architecture
All organization-scoped reads and mutations require authenticated membership. A resource ID or organization ID supplied by a client is never sufficient authorization. API keys derive their tenant from their stored record. Demo session IDs and workspace IDs are separate; each sandbox contains its own seeded workspaces.
PGlite runs PostgreSQL in-process for Docker-free local development. It is not a fake in-memory business store. The production driver uses PostgreSQL through `pg`; the schema and data contracts stay the same. PGlite is a single-process development database, not a production multi-worker replacement. The same additive initial schema is applied through both drivers. The public demo runs PostgreSQL 17 in a private container; its initialization and live application requests were verified.
## Billing, invitations and API keys
Mock billing allows safe plan changes, cancellation and reactivation without money. Provider webhooks verify signatures and deduplicate stored event IDs before state transitions. The official Stripe SDK adapter verifies subscription-event fixtures; it is injected through `createPlatform({ billingProvider })`, not activated by an environment switch. Production checkout, price/customer mapping and handling out-of-order provider events still need integration. Live Stripe calls were not tested.
Invitation tokens and API keys are cryptographically random and hashed before storage. Tokens expire and can be used once. Plaintext API keys are shown only when created. Demo outbox messages contain a non-secret workspace link and invitation ID; acceptance stays inside your sandbox. Normal invitations deliver their bearer token only through a configured email provider. The outbox is not an audit log or a production email service.
For the example API, create a key with project-read scope in the UI:
```sh
curl http://localhost:3000/api/v1/projects \
-H "Authorization: Bearer YOUR_NEWLY_CREATED_KEY"
```
Do not commit the key. Requests are tenant-scoped and tracked as usage. The UI displays actual stored usage and audit records; seed activity is fictional and labeled.
## Configuration
`.env.example` documents local and production settings. `pnpm demo` supplies safe development configuration without an environment file. Production requires a stable, independently generated `BETTER_AUTH_SECRET`, PostgreSQL URL and exact HTTPS application origin. Leave OAuth and Stripe credentials blank for the public demo. Real email delivery is injected through `createPlatform({ emailProvider })`; normal production invitations refuse to send without it.
Normal local sign-up uses Better Auth and a separate account session. Its verification email is available from the authenticated development outbox only on localhost with demo mode enabled. Invitation acceptance requires the verified recipient email. The database initializes its idempotent initial schema automatically; future schema upgrades need versioned migrations.
Public attribution is configured with `PUBLIC_PORTFOLIO_URL`, `PUBLIC_CONTACT_EMAIL`, `PUBLIC_TELEGRAM_URL` and optional `PUBLIC_SOURCE_URL`. The Source link is hidden when no real source URL is configured. None of these public settings may contain secrets.
## Testing
```sh
pnpm lint
pnpm format:check
pnpm typecheck
pnpm test:unit
pnpm test:integration
pnpm test:browser
pnpm build
```
Playwright tests require an installed Chromium browser (`pnpm exec playwright install chromium`). Vitest uses isolated local test databases. [QA record](docs/QA.md) records actual counts and outcomes. [Security review](docs/SECURITY_REVIEW.md) records verified protections and outstanding production boundaries.
## Security and production notes
Treat membership, RBAC, key scopes, invitation recipient identity, webhook verification and platform permissions as server responsibilities. Session cookies are HttpOnly; cookie-authenticated mutations validate the request origin. Validate all input, bound request sizes, use parameterized queries and never log secrets. Audit records are written only by server operations and must not include passwords or plaintext tokens.
For a commercial deployment, configure HTTPS, durable secrets, verified email delivery, required providers, backups/restore drills, monitoring and retention policies. Distributed deployments require shared rate limiting and production database tests. Review the documented demo TTL and cleanup behavior before exposing public sandboxes. Mock billing is not a completed live payment integration.
Docker/Compose files provide a PostgreSQL-backed deployment architecture. Generate independent random `POSTGRES_PASSWORD` and `BETTER_AUTH_SECRET`, set the exact HTTPS `APP_URL`, and validate the image/Compose stack in the target environment. The public-demo image, private PostgreSQL service and HTTPS gateway were built and exercised; evidence is in the [QA record](docs/QA.md). See [deployment notes](docs/DEPLOYMENT.md) for resource limits, six-hour sandbox cleanup and safe operation. Never remove persistent volumes during upgrades.
## Limitations
This is a reusable product foundation, not a finished industry-specific SaaS. It includes one resource type, not a full project management suite. Email stays in the development outbox and billing uses mocks. Commercial plan entitlements are illustrative, not enforced quotas. Rate limiting is per process and needs a shared store for multiple instances. Ownership transfer, provider checkout, external email delivery and versioned schema upgrades remain extension points. Live OAuth, email and Stripe were not tested. PostgreSQL was tested on the public demonstration, without high-load or failover testing. The public demonstration uses isolated temporary sandboxes; it is not a production customer service.
## Author & Custom Development
Built and maintained by **bububi / Alexander** — [@shipap](https://github.com/shipap).
Need a custom version, integration, deployment, or a similar SaaS product?
Portfolio: [https://bububi.icu](https://bububi.icu)
Email: [[email protected]](mailto:[email protected])
Telegram: [https://t.me/o3amfeels](https://t.me/o3amfeels)
GitHub: [https://github.com/shipap](https://github.com/shipap)
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

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