Multi-tenancy
Multi-tenancy is an architecture in which one installation of an application serves several customers, the tenants, while keeping each tenant's data and settings separate from the others. The separation must be enforced where the data lives, not in the interface, and Meadowstack 2.1 leaves that wall to your backend while its rules keep other clients' records out of every screen.
By Bohuslav PoláčekChecked
| Design | How tenants are separated | Where a mistake leaks |
|---|---|---|
| Shared tables | Every row carries the tenant's id; row-level security policies compare it with the signed-in person's tenant | A table without a policy, or an api role that bypasses row security |
| Schema per tenant | Each tenant has its own schema with the same tables; the connection picks the schema | Code that sets the wrong schema for a request |
| Database per tenant | Each tenant has its own database and credentials | Credentials or a backup that reaches the wrong tenant |
Why it matters in a business app
The first serious leak in a business app is rarely a hacker; it is one client seeing another client's invoice because a query forgot a filter. A studio that builds one app for many franchisees, or a product sold to several companies, lives with that risk on every new screen.
Shared tables with row-level security are the usual start, because one schema is easier to migrate. PostgreSQL's warning applies twice here: superusers, roles with BYPASSRLS and, unless the table forces row security, its owner all bypass the policies, and then every tenant sees every row.
How Meadowstack handles it
In 2.1, honestly:
- No tenant model ships. The starter is one company; the Supabase example has no tenant column. The demo's several companies are separate simulated datasets, not a multi-tenant backend.
- The rule that comes closest is in the root AGENTS.md: an external role (client, customer, guest) never sees internal costs, margins or other clients' records, in widgets, feeds, the bell, search and assistant answers as on the pages, and screens ask with the record,
can("site.read", site). - What you add: a tenant id on every row, set by the server from the session, policies that compare it, an api role bound by them, and a test that signs in as one tenant and asks for another's records.
Meadowstack 3.0, coming as an update to every licence, adds the rule "check ownership on every record action: the record belongs to the user's organisation" to the rules coding tools follow.
Common mistakes
- The tenant id from the browser. It comes from the session on the server, never from a field the page sends.
- Filtering in the api only. One forgotten
whereis a leak; a policy in the database holds when the api forgets. - Shared caches and search indexes. A cache key or an index without the tenant serves one tenant's answer to another.
- Exports and the assistant. They read through a different path; give them the same rule.
Sources
Questions
Is a multi-tenant app less secure than one installation per client?
Not by design, but a mistake reaches more people. Shared tables need the separation enforced in the database and tested; separate databases trade that risk for more to run and update.
Can I build a multi-tenant SaaS with Meadowstack?
Yes, with your own backend: the interface, the permission rules and the screens are the same, and the tenant wall lives in your api and database.
Where should the tenant id come from?
From the signed-in person's session or token, read on the server. The browser may show it, never decide it.
Two ways
Build it yourself, or have it built
Build it yourself
Build your app on the framework
Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.
One payment, lifetime updates
Get the frameworkHave it built
Have us build your app
Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.
After launch, Care keeps it improving, from €99 a month.
from €1,990
Describe your app