TenancyJS
Getting Started

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:

  1. An integration for your framework - Express, Next.js, NestJS, or AdonisJS.
  2. 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 init

Today it ships ready-made templates for these six popular combinations:

FrameworkORMtenancy init
ExpressPrisma✅ scaffolded
ExpressTypeORM✅ scaffolded
ExpressSequelize✅ scaffolded
ExpressDrizzle✅ scaffolded
AdonisJSLucid✅ scaffolded
Next.jsPrisma✅ scaffolded

Add the packages it wired (for Express + Prisma):

npm install tenancyjs-core tenancyjs-adapter-prisma tenancyjs-integration-express

Then 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.

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.

PackageRole
tenancyjs-coreFramework-neutral tenant context, lifecycle, and the runtime contract
tenancyjs-identifiersResolve a tenant from a request (subdomain, header, path…)
tenancyjs-adapter-prisma · -knex · -lucid · -typeorm · -sequelize · -drizzle · -mongooseEnforce isolation inside your ORM (guides)
tenancyjs-integration-express · -next · -adonis · -nestBind context to the request lifecycle (guides)
tenancyjs-cliThe operational CLI (tenancy …)
tenancyjs-testingFixtures 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.

On this page