Skip to main content
Hostwares

Supabase Multi-Tenancy: Separate Data for Teams and Organizations

sowad sheikh··2 min read

A team-based application often has a simple requirement:

Multiple people should work together, but each organization should have its own data.

Supabase can support this structure using PostgreSQL tables and RLS.

Organizations

Start with an organizations table:

organizations
-------------
id
name
created_at

Then create a membership table:

organization_members
--------------------
organization_id
user_id
role

User Membership

Instead of putting a single organization directly on a user, a membership table can allow users to belong to multiple organizations.

For example:

Mahafuz → Company A
Mahafuz → Company B

Roles

Membership records can include roles:

owner
admin
member

The application can use these roles to control permissions.

Organization Data

Business records can reference the organization:

projects
tasks
documents
invoices

Each record can contain:

organization_id

Database Protection

RLS can check whether the authenticated user belongs to the organization associated with a record.

That makes the database responsible for enforcing tenant boundaries.

Switching Organizations

If users belong to multiple teams, the application can provide an organization switcher.

For example:

Current workspace:
[ Acme Inc. ▼ ]

The application changes the active organization while database policies continue protecting the data.

Final Thoughts

A clean organization model makes team applications easier to maintain.

Use organizations, memberships, roles and tenant-aware records as the foundation.

Then use RLS to enforce those boundaries.

Ready to deploy?

Launch your app on Hostwares — start for $1.00/mo with auto-scaling & global CDN.

Start for $1.00/mo

Ready to deploy? Start for $1.00/mo

Deploy now