How to Build Role-Based Access Control (RBAC) in Bubble.io
In every B2B SaaS, different users need different levels of access. Owners manage billing. Admins manage teams. Members create data. Viewers read it. This guide shows you how to build RBAC in Bubble that is enforced at both the UI and the server.
Roles Live on Membership Records, Not User Records
The most common RBAC mistake in Bubble is adding a role field to the User data type. This fails immediately for multi-tenant SaaS because the same user can be an Admin in Workspace A and a Viewer in Workspace B. Role is not a property of a person — it is a property of their relationship to a specific workspace. That relationship is the Membership record.
User: role → option set ← breaks in multi-tenant apps
// ✅ Correct — role on Membership is per-workspace
Membership:
user → User
workspace → Workspace
role → Workspace_Role (option set) ← here
status → Membership_Status (option set)
Define Roles as an Option Set
OWNER — full control, billing, workspace deletion
ADMIN — manage team, settings, all data
MEMBER — create and edit own data, view all
VIEWER — read-only, no create or edit
// Helper expression — define once, reuse everywhere
Current_Role =
Search for Memberships [
user = Current User,
workspace = Current User’s current_workspace,
status = Active
] : first item’s role
Two-Layer Enforcement: UI + Backend
Element visible when:
Current_Role is in [Admin, Owner]
// Hide “Delete Workspace” from non-owners
Element visible when:
Current_Role = Owner
Only when:
Search for Memberships [
user = Current User,
workspace = target workspace,
role is in [Admin, Owner],
status = Active
] : count > 0
What Each Role Can Do
| Action | Owner | Admin | Member | Viewer |
|---|---|---|---|---|
| View all workspace data | ✓ | ✓ | ✓ | ✓ |
| Create records | ✓ | ✓ | ✓ | ✗ |
| Edit own records | ✓ | ✓ | ✓ | ✗ |
| Edit others’ records | ✓ | ✓ | ✗ | ✗ |
| Delete records | ✓ | ✓ | Own only | ✗ |
| Invite members | ✓ | ✓ | ✗ | ✗ |
| Remove members | ✓ | ✓ | ✗ | ✗ |
| Manage billing | ✓ | ✗ | ✗ | ✗ |
| Delete workspace | ✓ | ✗ | ✗ | ✗ |
| View audit log | ✓ | ✓ | ✗ | ✗ |
Ready to Build on Bubble?
Architecture, data model design, Stripe billing, and full SaaS builds — done right from day one.
