Installation
Start with the CLI - it scaffolds your tenancy for your stack. Or wire it up by hand.
Requirements
- Node.js 24+ - the toolkit and CLI use modern Node features, and the CLI loads your TypeScript config via Node's native type-stripping (no transpiler needed).
- TypeScript is recommended but not required.
Two independent choices: framework × ORM
TenancyJS composes from two axes that don't need to know about each other:
- An integration for your framework - Express, Next.js, NestJS, or AdonisJS.
- An adapter for your ORM - Prisma, Knex, Lucid, TypeORM, Sequelize, Drizzle, or Mongoose.
Integrations and adapters compose through the same TenancyManager; they do not import each other.
That makes combinations such as Express + Sequelize, Next.js + Knex, and NestJS + Mongoose
architecturally valid. Not every Cartesian pairing has its own dedicated E2E yet, so use the documented
adapter capability plus the integration lifecycle evidence and add an application-level isolation test
for your exact pairing.
Framework and ORM support are orthogonal contracts. The capability matrix records database/strategy proof; the testing guide shows how to prove your exact application pairing.
Fastest path: scaffold with the CLI
tenancy init writes a working tenancy.config.ts, tenant registration, and request middleware for
you - no boilerplate.
npx tenancy initToday it ships ready-made templates for these six popular combinations:
| Framework | ORM | tenancy init |
|---|---|---|
| Express | Prisma | ✅ scaffolded |
| Express | TypeORM | ✅ scaffolded |
| Express | Sequelize | ✅ scaffolded |
| Express | Drizzle | ✅ scaffolded |
| AdonisJS | Lucid | ✅ scaffolded |
| Next.js | Prisma | ✅ scaffolded |
Add the packages it wired (for Express + Prisma):
npm install tenancyjs-core tenancyjs-adapter-prisma tenancyjs-integration-expressThen jump to the Quickstart.
Any other combination - Express + Knex, Next.js + Knex, NestJS + anything - isn't scaffolded yet, but it's a few lines of manual wiring. Follow manual setup below.
The CLI does more than scaffold
init is just the start. The same CLI lists, creates, migrates, provisions, and runs scripts against
your live tenants. See the full CLI reference →.
Set up your framework
Pick your framework for the complete, copy-paste wiring. Each guide works with any of the ORMs listed below it - just install that adapter and use the same steps.
Express
Prisma · Knex · TypeORM · Sequelize · Drizzle · Mongoose
Next.js
Prisma · Knex · TypeORM · Sequelize · Drizzle · Mongoose
NestJS
Prisma · Knex · TypeORM · Sequelize · Drizzle · Mongoose
AdonisJS
Lucid
Or browse by ORM adapter if you prefer.
Manual setup
Works for any framework × ORM. Install three things: the core, your framework's integration, and your ORM's adapter. For example, Express with Sequelize:
bash npm install tenancyjs-core tenancyjs-integration-express tenancyjs-adapter-sequelize bash pnpm add tenancyjs-core tenancyjs-integration-express tenancyjs-adapter-sequelize bash yarn add tenancyjs-core tenancyjs-integration-express tenancyjs-adapter-sequelize bash bun add tenancyjs-core tenancyjs-integration-express tenancyjs-adapter-sequelize Then follow the two guides for your choices - the integration guide for the framework half and the adapter guide for the ORM half. That's the whole wiring.
| Package | Role |
|---|---|
tenancyjs-core | Framework-neutral tenant context, lifecycle, and the runtime contract |
tenancyjs-identifiers | Resolve a tenant from a request (subdomain, header, path…) |
tenancyjs-adapter-prisma · -knex · -lucid · -typeorm · -sequelize · -drizzle · -mongoose | Enforce isolation inside your ORM (guides) |
tenancyjs-integration-express · -next · -adonis · -nest | Bind context to the request lifecycle (guides) |
tenancyjs-cli | The operational CLI (tenancy …) |
tenancyjs-testing | Fixtures and conformance helpers for your own tests |
During the beta the packages are published under the beta dist-tag. A plain npm install tenancyjs-core resolves the latest published beta; pin an exact version for reproducibility.