◉RORK LABJP
●SUBDOMAIN — Rork can now connect your web app to a subdomain only, leaving your root domain and www untouched (12/1)●UPDATES — expo-updates 58.0.23 fixes Android release builds embedding a stale runtime version●FLASH END — Intro pricing for Gemini Flash models ends 12/31, 29 days from now. Time to recheck AI feature costs●HMR — Some report the dev server picking up another server's bundle and then exiting●FIRST VIEW — Map the first screen for a normal launch, a notification, and a link, and back navigation stops surprising you●CARBON — Gemini 4 Carbon and Argon are now at standard rates: $4.00 input, $20.00 output per 1M tokens●SUBDOMAIN — Rork can now connect your web app to a subdomain only, leaving your root domain and www untouched (12/1)●UPDATES — expo-updates 58.0.23 fixes Android release builds embedding a stale runtime version●FLASH END — Intro pricing for Gemini Flash models ends 12/31, 29 days from now. Time to recheck AI feature costs●HMR — Some report the dev server picking up another server's bundle and then exiting●FIRST VIEW — Map the first screen for a normal launch, a notification, and a link, and back navigation stops surprising you●CARBON — Gemini 4 Carbon and Argon are now at standard rates: $4.00 input, $20.00 output per 1M tokens
Articles/Dev Tools
⬡ Dev Tools/2026-04-01Advanced

Building a B2B SaaS App with Rork: Multi-Tenant Architecture, RBAC, and Stripe Organization Billing

A complete guide to building production-grade B2B SaaS apps with Rork. Learn multi-tenant architecture, role-based access control (RBAC), organization-level Stripe billing, and invitation flows with real code examples.

Rork622B2BSaaS3Multi-TenantRBACStripe20Supabase41App Development33Advanced4

✦ Premium Article

Setup and context — Why B2B SaaS Is the Most Scalable Model for Independent Developers

When you're building and shipping apps as a solo developer or small team, B2B (business-to-business) apps tend to outperform B2C (consumer) apps on revenue sustainability. Organizations contract at the team level, meaning a single contract generates recurring revenue for as long as it remains active. The switching cost of a team tool is high, which translates to lower churn rates and longer customer lifetime values.

But building B2B SaaS introduces design challenges that don't exist in consumer apps:

  • Multi-tenancy: Safely isolate data across multiple organizations (tenants)
  • RBAC: Assign roles to team members and restrict access to screens and features
  • Organization billing: Charge at the organization level via Stripe, with tier-based plans
  • Invitation flow: Allow existing members to invite new colleagues into the organization

In this guide, you'll learn how to implement all of these with Rork, complete with real Supabase schema design and working code. If you're new to Supabase auth, check out Supabase Auth and Realtime Integration Guide first.


Multi-Tenant Architecture Design

Three Data Isolation Strategies

Multi-tenancy can be implemented in three main ways:

Strategy 1: Database per Tenant Each tenant gets its own database. Maximum security, but high cost and maintenance overhead — typically reserved for enterprise-tier plans.

Strategy 2: Schema per Tenant One database, separate PostgreSQL schemas per tenant. Supports per-tenant Row Level Security policies, but adds complexity to migrations.

Strategy 3: Shared Schema + Row Level Security All tenants share the same tables, separated by an organization_id column. Combined with Supabase's RLS, this is the most cost-effective approach for indie developers and small teams — and the one we'll use here.

Supabase Schema Design

Run the following SQL in your Supabase dashboard's SQL Editor:

-- Organizations table
create table organizations (
  id uuid primary key default gen_random_uuid(),
  name text not null,
  slug text unique not null,
  plan text not null default 'free', -- free / starter / growth / enterprise
  stripe_customer_id text,
  stripe_subscription_id text,
  max_members int not null default 3,
  created_at timestamptz default now()
);
 
-- Organization members (user-to-org mapping + role)
create table organization_members (
  id uuid primary key default gen_random_uuid(),
  organization_id uuid references organizations(id) on delete cascade,
  user_id uuid references auth.users(id) on delete cascade,
  role text not null default 'member', -- owner / admin / member / viewer
  invited_by uuid references auth.users(id),
  accepted_at timestamptz,
  created_at timestamptz default now(),
  unique(organization_id, user_id)
);
 
-- Invitations table
create table invitations (
  id uuid primary key default gen_random_uuid(),
  organization_id uuid references organizations(id) on delete cascade,
  email text not null,
  role text not null default 'member',
  token text unique not null default encode(gen_random_bytes(32), 'hex'),
  invited_by uuid references auth.users(id),
  expires_at timestamptz default now() + interval '7 days',
  accepted_at timestamptz,
  created_at timestamptz default now()
);
 
-- Enable RLS
alter table organizations enable row level security;
alter table organization_members enable row level security;
alter table invitations enable row level security;

Setting Up Row Level Security Policies

-- Users can only view organizations they belong to
create policy "users can view their organizations"
on organizations for select
using (
  id in (
    select organization_id from organization_members
    where user_id = auth.uid()
    and accepted_at is not null
  )
);
 
-- Members can view other members in their org
create policy "members can view own org members"
on organization_members for select
using (
  organization_id in (
    select organization_id from organization_members
    where user_id = auth.uid()
    and accepted_at is not null
  )
);
 
-- Only owner/admin can manage invitations
create policy "admins can manage invitations"
on invitations for all
using (
  organization_id in (
    select organization_id from organization_members
    where user_id = auth.uid()
    and role in ('owner', 'admin')
    and accepted_at is not null
  )
);

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦Master multi-tenant architecture best practices and implement database-level data isolation using Supabase Row Level Security
✦Build a 4-tier RBAC system (Owner, Admin, Member, Viewer) in Rork and apply permission gates to every screen
✦Implement organization-level Stripe subscriptions, member-count billing tiers, and a customer billing portal from scratch
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⬡ Dev Tools2026-11-19
New Wallpapers Showed Up Everywhere Except the Filters: Ship the Count and the Category Lists Together
I added 67 wallpapers in one batch. They appeared in the full list and in New, but not under a single category filter, because I had raised the ID limit and forgotten to ship the category lists. Here is a pre-bump check, a client-side way to spot silent fallbacks in an Expo app, and a post-release count against the origin.
⬡ Dev Tools2026-11-04
Catching the Few Seconds Before Streaming Audio Starts: A Loading State and a Timeout
You tap play and nothing happens for a moment. Here is how I model that gap with expo-audio: a requested flag, a 400ms delayed spinner, and an 8-second timeout.
⬡ Dev Tools2026-10-30
It runs in development but the iOS Release build dies on launch — checking whether a missing scheme is the cause
In an expo-router app, an app.json with no scheme can crash only the iOS Release build at launch. A triage table for Release-only crashes, how to read the reason from the log, why Debug and Android survive, the two fixes and why one needs a native rebuild, and a pre-submission check.