Home
Multitenant — config-driven tenant and market resolution for TypeScript.
Config-driven tenant and market resolution for TypeScript: one tenants.config.json, createTenantRegistry, and adapters for Next.js (App + Pages), Express, Nest, and React — with typed errors you can branch on in production.
Adapters & packages
Every adapter expects a TenantRegistry from createTenantRegistry(config) where config is your validated TenantsConfig (JSON file, loadTenantsConfig, or validateTenantsConfig after a CMS map).
Scaffold stubs: npx @multitenant/cli init --framework ….
| Package | Use case |
|---|---|
@multitenant/next / next-app / next-pages | Next.js — meta package, App Router, Pages Router — guide |
@multitenant/react | TenantProvider, hooks — guide |
@multitenant/express | multitenantExpress → req.tenant — guide |
@multitenant/nest | MultitenantModuleForRoot, @Tenant() — guide |
@multitenant/drizzle / kysely / prisma / typeorm | Reference ORM wiring — pools per tenant; see Packages |
Edge vs Node (App Router)
| Runtime | Resolve tenant | DB / Node APIs |
|---|---|---|
| Edge middleware | Yes — thin, static JSON | No |
| Node server | getTenantFromHeaders / requireTenant | Yes — e.g. @multitenant/database ALS |
Details: Next.js — App Router.
Read next
- Why Multitenant? — mental model, when not to use this, pitfalls.
- Quick start —
init+checkin two commands. - Getting started — install, minimal config, validation, async/bootstrap.
- Configuration —
tenants.config.jsonschema, flags, merge rules. - Packages — scoped
@multitenant/*installs at a glance. - Examples — Express and Next.js (App Router) walkthroughs (
express-minimal,next-minimal). - Errors —
MultitenantErrorhierarchy and stablecodestrings. - CLI —
init,devproxy,check,print.
The monorepo also ships reference ORM packages (Drizzle, Kysely, Prisma, TypeORM) and @multitenant/database (ALS scope). Deep-dive markdown for contributors remains in the GitHub docs/ tree.