Organizations
Multi-tenancy via Clerk Organizations: switching organizations, roles, and scoping billing and data by organization.
The organization, not the individual user, is the tenancy boundary: subscriptions, billing status, and app data are all scoped by organization ID rather than user ID. A user can belong to more than one organization and switch between them.
Switching organizations
The sidebar (src/app/[locale]/(saas)/_components/app-sidebar.tsx) renders
Clerk's <OrganizationSwitcher> with hidePersonal set, so every signed-in
user operates inside an organization context — there's no "personal
workspace" fallback. Creating, selecting, or leaving an organization all
redirect back into the app (afterCreateOrganizationUrl,
afterSelectOrganizationUrl, afterLeaveOrganizationUrl). See
Clerk's Next.js SDK reference
for the full <OrganizationSwitcher> prop list and Clerk's organization
APIs.
Organization roles
Clerk Organizations ship with two
built-in roles:
org:admin, with full access to the organization, and org:member, limited
to read-only access by default. This kit only checks for org:admin — every
other authenticated feature is open to any organization member:
- The Billing tab in the organization profile only renders for admins — non-admins visiting
/app/organization/billingare redirected back to/app/organization(organization/[[...rest]]/page.tsx). openBillingPortal()(_actions/billing.ts) throwsUnauthorizedunless the caller has theorg:adminrole.- Checkout sends non-admins to the dashboard instead of Stripe, and the upgrade gate shows them "Ask an admin of your organization to choose a plan" instead of plan buttons. Invited members who sign up are never asked to pay for the organization.
No dedicated admin panel ships with the kit for managing users and
organizations directly — that's what the
Clerk Dashboard is for. The
org:admin role already gates billing management in-app, and the same
has({ role: 'org:admin' }) check (from const { has } = await auth())
can be reused to gate any other sensitive, org-scoped action you add.
Org-scoped data
src/db/schema/billing.ts's org_subscriptions table is keyed by
org_id, not a user ID — follow this pattern for any new app data you
add. Take the orgId from auth() on the server, never from the client.
Build Your First Feature shows the whole pattern, and
Multi-Tenant SaaS Architecture covers
other database models and adding Postgres row-level security.
Further reading: Multi-Tenant SaaS Authentication in Next.js: A Complete Guide with Clerk Organizations walks through this whole model — switching, roles, and org-scoped data — end to end.