Establish isolated database strategies, coordinate organizational lifecycles, and enable secure resource sharing across customer boundaries with zero context leakage.
import express from 'express';
import { TenantManager } from '@node-tenant/tenant-core';
import { tenantMiddleware } from '@node-tenant/tenant-express';
import mongoose from 'mongoose';
import { tenantMongoosePlugin } from '@node-tenant/tenant-mongoose';
mongoose.plugin(tenantMongoosePlugin);
const manager = new TenantManager({ storage });
const app = express();
// Resolve tenant automatically from subdomain
app.use(tenantMiddleware({ manager }));
app.get('/users', async (req, res) => {
// Auto-filters query: WHERE tenant_id = 'acme'
const users = await User.find();
res.json(users);
});Building SaaS platforms from scratch is complex. We provide a bulletproof, modular structure so you can build safe architectures without vendor lock-in.
Share a single database server across thousands of customers using tenantId or schema separation to minimize server footprints and billing.
Fully ORM-agnostic (Prisma, Mongoose, TypeORM, Sequelize) and framework-agnostic (Express, Next.js, Fastify, NestJS). Choose your own stack.
Protect sensitive corporate data. Our query interceptors ensure database actions are locked into the resolved context automatically.
Configure different isolation models per tenant. Run hybrid environments where free tier accounts share tables, while enterprise accounts receive isolated databases.
All tenants share the same database tables. Every table includes a tenant ID column. The ORM intercepts operations to inject context filters automatically.
Tenants reside in the same database server but utilize distinct database schemas (e.g. Postgres schemas). Connection paths are altered dynamically.
Every tenant is assigned a completely isolated physical database. The application dynamically switches connections based on request routing.
Take advantage of our 7 modular packages to deploy stable, high-performance backends.