Multi-tenant data isolation: queries are scoped by organizationId and do not rely on route parameters alone
TenantKit-Lite — Next.js SaaS Template
By Thaelith
TenantKit-Lite is a multi-tenant SaaS starter built on Next.js, using Prisma and SQLite, with built-in RBAC, an invitation flow, audit logs, Vitest unit tests, and GitHub Actions CI.
Explore the design
Compare the page layouts and mobile experience. Open any screenshot for a closer look.
Preview provided in the project README.
One original preview is available. Open the full image to inspect the design.
Screenshots show visual appearance; interactive behavior may differ.
What stands out
A quick read of the recorded project description.
RBAC role model: three levels—OWNER, ADMIN, MEMBER—with server-side permission validation
Token-based member invitation flow, including registration guidance and invitation consumption
Audit logs record the actor, action, entity, and JSON metadata
Uses Vitest to cover logic such as tenant isolation, role boundaries, and token expiration
GitHub Actions runs lint, type checking, build, and tests on pushes and PRs
Template Details
TenantKit-Lite is a multi-tenant starter aimed at B2B SaaS scenarios, intended to demonstrate enterprise-grade foundational capabilities in a local development environment without relying on Docker or PostgreSQL. It uses a file-based SQLite database and can run immediately after cloning.
The project organizes data around six core models: User, Organization, Membership, Invitation, Project, and AuditLog. Authentication uses Auth.js (NextAuth v4) with email/password, and passwords are hashed with bcryptjs; after registration, a default organization is automatically created and the user is assigned the OWNER role. Protected resources are strictly scoped by organizationId at the query layer, avoiding unauthorized access that would result from relying solely on route parameters. Roles are OWNER, ADMIN, and MEMBER, and permissions are validated server-side. The invitation flow generates links via tokens with expiration times; after the invitee registers or logs in, a Membership is created and the invitation is consumed. Audit logs record actorId, action, entityId, and JSON metadata, and are used to review the history of key operations within an organization.
The tech stack includes Next.js App Router, TypeScript, Tailwind CSS, Prisma, SQLite, Auth.js, Zod, Lucide React, and Vitest. Tests focus on business logic such as tenant isolation, role boundaries, token expiration, and audit integration. GitHub Actions runs lint, type checking, build, and unit tests on pushes and pull requests. The repository provides a seed script to generate demo data, along with demo scripts and a manual QA checklist document.
Limitations: the project is positioned for demonstration and portfolio purposes, and the README does not declare a production deployment plan; SQLite is suitable for local development, and switching to a production database requires adjusting the Prisma configuration yourself; external services (domain, hosting, database, payment, or AI) may incur additional costs; third-party assets such as demo images, fonts, and icons require separate license verification.
Is it right for your project?
Use Cases
- Learning how Next.js App Router and Server Actions are organized in multi-tenant scenarios
- Quickly setting up a SaaS prototype with RBAC and an invitation flow locally
- Referencing query-layer tenant isolation patterns to avoid IDOR-type unauthorized access
- Adding traceable audit logs for key operations within an organization
- Using it as a portfolio project to demonstrate the integration of authentication, permissions, and testing
Suitable For
- Developers who need a local zero-dependency database to quickly start a multi-tenant project
- Next.js developers who want to reference implementation details of RBAC and invitation flows
- Individuals or small teams preparing to build a B2B SaaS prototype and needing a foundation for audit logs
Getting started & customization
Use these recorded setup notes alongside the repository instructions for your chosen version.
- 1
Requires Node.js 20.9+ and npm 9+
- 2
Copy .env.example to .env and generate NEXTAUTH_SECRET
- 3
Run npx prisma migrate dev --name init to initialize the SQLite database
- 4
Run npm run seed to generate demo users, projects, and audit logs; the demo password is demo123
- 5
If session issues occur after seeding or deleting the local database, clear the localhost cookie or log out and log in again
License & source material
Usage conditions & limitations
Free to use · keep license noticeThis listing covers the free version under the MIT license in the public repository; the free scope is the code of that version and does not mean that external services or third-party assets are free.
Must comply with when using
- You may use, modify, commercially use, and distribute the code of this version for free.
- When distributing copies or substantial portions of the code, retain the original author's copyright notice and the full MIT license notice.
- The code is provided as is; warranties and limitations of liability are governed by the original license and applicable law.
Additional costs & items to verify
- Demo images, fonts, icons, and other third-party assets must be checked against their respective licenses and cannot be judged solely by the code's MIT license.
- External services such as domain, hosting, database, payment, or AI may incur separate charges.
- The project uses a file-based SQLite database, making it easy to clone, run, and learn from locally without Docker or PostgreSQL; if a different database is needed in production, you must adjust the Prisma configuration yourself.
- The repository is positioned as a portfolio showcase project, and the README does not declare a production deployment plan or guarantee production readiness.
- The demo account password is uniformly demo123, intended only for local demo data, and should not be used as real-environment credentials.
- After running seed or manually deleting the local database, the browser may retain a session cookie for a user that no longer exists, causing 'No organization access' or looping behavior; you need to log out or clear the localhost cookie and log in again.
- You must provide the NEXTAUTH_SECRET environment variable yourself; otherwise authentication will not work properly.
- Local operation requires a Node.js 20.9+ and npm 9+ environment.
View Original Text Basis
Permission is hereby granted, free of charge
Original License Text
It uses a file-based SQLite database so developers can clone, run, and learn without needing Docker or PostgreSQL.
Original README
This repository serves as a portfolio piece showcasing:
Original README
**Demo Credentials (all passwords are `demo123`):**
Original README
If running `npm run seed` or manually deleting the local database causes a "No organization access" or loop behavior, it means your browser has a stale session cookie for a user that no longer exists in the database.
Original README
| `NEXTAUTH_SECRET` | Auth.js JWT encryption secret | *(must be provided)* |
Original README
https://github.com/Thaelith/TenantKit-Lite/blob/main/LICENSEhttps://github.com/Thaelith/TenantKit-Lite/blob/main/README.md- Node.js 20.9+ (Recommended for Next.js 15)
Original README
Compiled by DeepSeek based on repository license and README ·2026-10-04. Results only cover the materials read; dependencies, images, fonts, and subsequent term changes are subject to their respective original texts.
Project checks & description sources
Template Information
- Source platforms
- GitHub
- Documentation and maintenance reference score
- Partly documented · 73 / 100
- Technologies
- Next.js · React
- Website type
- SaaS · Starter
How this score is calculated
Our heuristic uses license records (up to 30), a demo link (12), a preview (10), stars (15), recorded maintenance (15), description completeness (8), feature records (5) and classification data (5). It is not a code, security or performance test, or a Google score. A link does not establish tested functionality.
What to verify for this project
- Repository update recorded
- 2026-04-27
- Screenshot last checked
- 2026-10-04
No demo link is recorded. Use the repository instructions to evaluate the project locally; the screenshot alone cannot establish interactive behavior.
The catalog identifies Next.js as the primary stack. Check the actual dependency manifest and lockfile for versions and hosting requirements. These notes use recorded metadata, not a code audit or a deployment test.
Use a selection guide →How this description was prepared
AI-assisted description based on catalog records and repository material. Repository authors are not automatically the reviewers of this description.
Review declaration: [email protected] · 2026-10-04
Inspect the recorded source material
SHA-256: d2749028979cf8151a9392275237d2d2eaa32be21ca7021544fd4e0d8dc3c591
2026-10-04T07:36:37.927Z
Source file / repository# TenantKit Lite [](https://github.com/Thaelith/TenantKit-Lite/actions)     A production-style multi-tenant SaaS starter built with Next.js, TypeScript, SQLite, Prisma, and robust Role-Based Access Control (RBAC). ## Why This Project Exists Many Next.js starter kits provide basic CRUD functionality but fail to address the complex requirements of true B2B SaaS applications. TenantKit Lite was built to demonstrate how to implement fundamental enterprise features—like hard tenant isolation, strict role-based access control, invitation workflows, and immutable audit logging—while keeping local development incredibly simple. It uses a file-based SQLite database so developers can clone, run, and learn without needing Docker or PostgreSQL. ## What This Demonstrates This repository serves as a portfolio piece showcasing: - **Security-First Design:** Structurally preventing Insecure Direct Object Reference (IDOR) attacks through query-level tenant isolation. - **Enterprise Capabilities:** Real-world implementations of RBAC and Audit Logging. - **Modern React Patterns:** Extensive use of Next.js App Router, Server Components, and Server Actions. - **Clean Architecture:** Keeping business logic testable and separated from UI components. ## Features - **Email/Password Authentication** — Register and login securely with bcryptjs password hashing via Auth.js. - **Auto-Workspace Creation** — New sign-ups automatically receive a default organization and the `OWNER` role. - **Multi-Tenant Architecture** — Isolated organizations and workspaces with unique slugs. - **Role-Based Access Control (RBAC)** — Strictly enforced `OWNER`, `ADMIN`, and `MEMBER` roles. - **Member Invitations** — Secure token-based invitation flow to add new members to workspaces. - **Tenant-Scoped Resources** — Queries are strictly scoped by `organizationId` to prevent cross-tenant data leaks. - **Audit Logging** — Automatic tracking of organization events (actor, action, entity, metadata). - **SQLite + Prisma** — Zero-dependency local database for instant setup. - **Fully Tested** — Unit tests cover critical security, isolation, and RBAC logic using Vitest. - **Automated CI** — GitHub Actions workflow ensures lint, build, and tests pass on every pull request. ## Demo & Seed Data You can quickly populate the database with realistic demo data, including users with different roles, projects, and audit logs. ```bash npm run seed ``` **Demo Credentials (all passwords are `demo123`):** - Owner: `[email protected]` (Full access) - Admin: `[email protected]` (Cannot access settings or delete org) - Member: `[email protected]` (Can only view/edit projects) > **Troubleshooting Note:** If running `npm run seed` or manually deleting the local database causes a "No organization access" or loop behavior, it means your browser has a stale session cookie for a user that no longer exists in the database. Simply click "Sign out" on the main landing page, or clear your localhost cookies, and log in with the new credentials. For a guided 5-minute walkthrough, see the [Demo Script](docs/demo-script.md). ## Screenshots ### Landing Page  ### Dashboard Overview  ### Projects  ### Members  ### Audit Logs  ## Tech Stack | Technology | Purpose | |---|---| | [Next.js 15](https://nextjs.org) | App Router, server components, API routes | | [TypeScript](https://www.typescriptlang.org) | Type safety and autocompletion | | [Tailwind CSS](https://tailwindcss.com) | Utility-first, responsive styling | | [Prisma](https://www.prisma.io) | ORM with strongly-typed queries | | [SQLite](https://www.sqlite.org) | Local-first, file-based database | | [Auth.js](https://authjs.dev) | Authentication (NextAuth v4) | | [Zod](https://zod.dev) | Input and API schema validation | | [Lucide React](https://lucide.dev) | SVG icon library | | [Vitest](https://vitest.dev) | Blazing fast unit testing framework | ## Architecture Overview ```text Browser ↓ Next.js App Router (React Server Components) ↓ Auth.js Session (Validates User Token) ↓ Permission Layer (Role + Membership Checks) ↓ Prisma ORM (Tenant-Scoped Queries) ↓ SQLite (file:./dev.db) ``` ## Database Schema Overview ```text User ──┬── Account (OAuth providers) ├── Session (auth tokens) └── Membership (Roles: OWNER, ADMIN, MEMBER) │ Organization ──┬── Project ├── Invitation └── AuditLog ``` The schema is built around six core models: `User`, `Organization`, `Membership`, `Invitation`, `Project`, and `AuditLog`. ## Tenant Isolation Notes Every protected resource is strictly scoped by `organizationId`. Queries never rely on route parameters alone — they always verify the current user's membership and permissions in the target organization. ```ts // Bad — No tenant scope (Vulnerable to IDOR) await prisma.project.findUnique({ where: { id: projectId } }); // Good — Strictly scoped by organization await prisma.project.findFirst({ where: { id: projectId, organizationId }, }); ``` ## Invitation Workflow 1. An `OWNER` or `ADMIN` generates an invitation link in the dashboard. 2. An `Invitation` record is created in the database with a secure, expiring token. 3. The recipient opens the link (`/invite/[token]`). 4. If they do not have an account, they are prompted to register. 5. Upon acceptance, a `Membership` record is created linking them to the organization, and the invitation is consumed. ## Audit Logging Critical actions (creating projects, editing resources, inviting members) are tracked. Audit logs capture the `actorId` (who did it), the `action` (what they did), the `entityId` (what was affected), and any relevant JSON metadata. This provides a transparent history for organization administrators. ## Testing & CI TenantKit Lite prioritizes logic validation over brittle UI tests. Essential business logic covering tenant isolation, role barriers, token expirations, and audit integrations are heavily tested using Vitest. - **Run tests locally:** `npm test` or `npm run test:watch` - **Continuous Integration:** GitHub Actions automatically runs linting, type-checking, builds, and unit tests on pushes and pull requests to `main`. ## Local Setup ### Prerequisites - Node.js 20.9+ (Recommended for Next.js 15) - npm 9+ ### Installation ```bash # Clone the repository git clone https://github.com/Thaelith/TenantKit-Lite.git cd TenantKit-Lite # Install dependencies npm install # Copy environment variables cp .env.example .env # Generate a secure NEXTAUTH_SECRET (or use the default for dev) node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" # Run Prisma migrations to initialize the SQLite database npx prisma migrate dev --name init # Start the development server npm run dev ``` Open [http://localhost:3000](http://localhost:3000) to see the application. ## Environment Variables | Variable | Description | Default | |---|---|---| | `DATABASE_URL` | SQLite database file path | `file:./dev.db` | | `NEXTAUTH_SECRET` | Auth.js JWT encryption secret | *(must be provided)* | | `NEXTAUTH_URL` | Application base URL | `http://localhost:3000` | ## Manual QA Checklist Before deploying or finalizing major features, refer to the [Manual QA Checklist](docs/manual-qa.md) located in the `docs/` folder to verify system integrity. ## Roadmap | Phase | Milestone | Status | |---|---|---| | 1 | Project foundation, Prisma schema, landing page | Complete | | 2 | Authentication (Auth.js, login, register, auto-workspace) | Complete | | 3 | Organization dashboard, settings, members | Complete | | 4 | Tenant-scoped project CRUD | Complete | | 5 | Role-based access control enforcement | Complete | | 6 | Member invitation workflow | Complete | | 7 | Audit logging | Complete | | 8 | Testing (Vitest, validation logic) | Complete | | 9 | CI & GitHub portfolio polish | Complete | | 10 | Portfolio readiness, seed data, screenshots, docs | Complete | ## Security Please see [SECURITY.md](SECURITY.md) for vulnerability reporting and architecture principles. ## Contributing Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to contribute. ## License [MIT License](LICENSE)
Explore similar templates
Compare previews and descriptions within the same stack and category.

Next.js SaaS Starter
The official Next.js SaaS starter template, integrating email/password authentication, Stripe Checkout subscriptions, a dashboard with user/team CRUD, basic Owner/Member RBAC, and activity logging.
Next.js · SaaS

Next.js Commerce
Vercel's officially maintained Next.js App Router ecommerce starter with deep Shopify integration, offering a complete product catalog, cart, and checkout flow. Core logic is modular for swapping backends, and community provider versions exist for BigCommerce, Medusa, and Saleor.
Next.js · E-commerce

Next-js-Boilerplate
A developer-first Next.js 16 starter with Tailwind CSS 4 and TypeScript, supporting both App Router and Page Router.
Next.js · Starter

tailwind-nextjs-starter-blog
A Next.js and Tailwind CSS blog starter template using Contentlayer for Markdown/MDX, with built-in SEO, code highlighting, and tags. It targets personal technical blogs and migration from Jekyll/Hugo to React, and supports one-click Vercel deployment.
Next.js · Blog

next-forge
next-forge is a Turborepo-based Next.js template maintained by Vercel, positioned as a starting point for SaaS products.
Next.js · Starter

SaaS-Boilerplate
SaaS-Boilerplate is an open-source SaaS starter template built with Next.js App Router, React 19, TypeScript, Tailwind CSS, and Shadcn UI.
Next.js · SaaS
