Multi-Tenant Plugin
This plugin sets up multi-tenancy for your application from within your Admin Panel. It does so by adding a tenant
field to all specified collections. Your front-end application can then query data by tenant. You must add the Tenants collection so you control what fields are available for each tenant.
Core features
- Adds a
tenant
field to each specified collection - Adds a tenant selector to the admin panel, allowing you to switch between tenants
- Filters list view results by selected tenant
Installation
Install the plugin using any JavaScript package manager like pnpm, npm, or Yarn:
Options
The plugin accepts an object with the following properties:
Basic Usage
In the plugins
array of your Payload Config, call the plugin with options:
Front end usage
The plugin scaffolds out everything you will need to separate data by tenant. You can use the tenant
field to filter data from enabled collections in your front-end application.
In your frontend you can query and constrain data by tenant with the following:
NextJS rewrites
Using NextJS rewrites and this route structure /[tenantDomain]/[slug]
, we can rewrite routes specifically for domains requested:
Examples
The Examples Directory also contains an official Multi-Tenant example.