Organizations and multi-tenancy
Startup+ tier org model, invitations, org switcher, settings, and data isolation patterns.
Overview
Multi-tenancy adds organizations, memberships, and org-scoped data. Enable it for SaaS and corporate templates; the base template carries models and middleware while templates add UI.
Data model
- Organization — name, slug, avatar
- Membership — user, organization, role
- Invitation — email, role, expiry, accept and decline flows
Org switcher
The header switcher sets the active organization in session or cookie context. All queries read the active org ID from middleware.
Isolation
Route handlers and server actions resolve organizationId from context and reject cross-tenant access. Add composite unique indexes on tenant-scoped tables.
Settings
Organization settings pages support logo upload via the storage adapter and billing linkage via payments.
Never trust client-supplied org IDs alone. Always validate membership server-side on every mutation.