Node Tenant Logo
node-tenant
Enterprise-Grade Multi-Tenancy

Modular Multi-Tenant Platform for Node.js

Establish isolated database strategies, coordinate organizational lifecycles, and enable secure resource sharing across customer boundaries with zero context leakage.

60-Second Setup (Express + Mongoose)

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);
});

Why use @node-tenant?

Building SaaS platforms from scratch is complex. We provide a bulletproof, modular structure so you can build safe architectures without vendor lock-in.

Cost Effectiveness

Share a single database server across thousands of customers using tenantId or schema separation to minimize server footprints and billing.

Absolute Flexibility

Fully ORM-agnostic (Prisma, Mongoose, TypeORM, Sequelize) and framework-agnostic (Express, Next.js, Fastify, NestJS). Choose your own stack.

Strict Data Isolation

Protect sensitive corporate data. Our query interceptors ensure database actions are locked into the resolved context automatically.

Flexible Database Strategies

Configure different isolation models per tenant. Run hybrid environments where free tier accounts share tables, while enterprise accounts receive isolated databases.

tenantId StrategyHighest Efficiency

All tenants share the same database tables. Every table includes a tenant ID column. The ORM intercepts operations to inject context filters automatically.

  • ✓ Lowest server maintenance cost
  • ✓ Ideal for early-stage SaaS
  • ✗ Logical isolation only
schema StrategyBalanced Isolation

Tenants reside in the same database server but utilize distinct database schemas (e.g. Postgres schemas). Connection paths are altered dynamically.

  • ✓ Clear database table separation
  • ✓ Simple database schema migrations
  • ✗ Moderate database connections pool
database StrategyHighest Security

Every tenant is assigned a completely isolated physical database. The application dynamically switches connections based on request routing.

  • ✓ Physical server-level separation
  • ✓ Zero risk of tenant cross-leakage
  • ✗ High infrastructure complexity

Build your multi-tenant backend today

Take advantage of our 7 modular packages to deploy stable, high-performance backends.