adonisjs-multi-tenancy

Implement multi-tenant architecture in AdonisJS applications with dynamic tenant connections.

2|1|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/omakei/adonisjs-architecture-skill --skill adonisjs-multi-tenancy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: adonisjs-multi-tenancy
Source: https://github.com/omakei/adonisjs-architecture-skill/tree/main/adonisjs/skills/adonisjs-multi-tenancy
Command: npx skills add https://github.com/omakei/adonisjs-architecture-skill --skill adonisjs-multi-tenancy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Multi-tenant architecture patterns for AdonisJS provide clear separation between central (landlord) and tenanted contexts, enabling dynamic tenant connections and strict data isolation in SaaS applications.

Core Features & Use Cases

  • Central vs tenanted architecture with per-tenant databases or schemas
  • Runtime tenant resolution via middleware and HttpContext integration
  • Dynamic ConnectionManager-backed tenant connections to avoid runtime config mutations
  • Actions and jobs that run within the correct tenant context
  • Testing strategies for central and tenanted flows (including migrations)

Quick Start

Start by configuring a central database, implementing tenant resolution middleware, and registering tenant connections to enable tenant-scoped queries.

Frequently Asked Questions about adonisjs-multi-tenancy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement multi-tenancy in an AdonisJS SaaS application?

You implement multi-tenancy by establishing central versus tenanted contexts, using middleware for runtime tenant resolution, and registering dynamic tenant connections to ensure strict tenant-scoped data isolation.

How does AdonisJS handle dynamic tenant database connections without mutating runtime config?

AdonisJS handles dynamic tenant connections by using a ConnectionManager-backed approach, passing tenant connections explicitly to actions and jobs to avoid mutating the runtime config.

What is the difference between central and tenanted contexts in a multi-tenant AdonisJS app?

Central context manages landlord-level operations and shared data, while tenanted context isolates queries and actions to a specific tenant's database or schema for strict data separation.

How do I run migrations for per-tenant databases in AdonisJS?

Per-tenant database migrations are executed by applying testing strategies that differentiate central and tenanted flows, ensuring schema changes propagate correctly to dynamically resolved tenant connections.

Can I use HttpContext to resolve tenant connections in AdonisJS?

Yes, runtime tenant resolution integrates directly with HttpContext via middleware to identify the tenant and register the appropriate ConnectionManager-backed tenant connection.

What are the limitations of using a multi-tenant architecture with database-per-tenant in AdonisJS?

Limitations include the complexity of managing dynamic connections and ensuring actions run in the correct tenant context, requiring strict adherence to central and tenanted action patterns.