Interactive Demo

Multi-Tenant Auth with Supabase

Enable true multi-tenant authentication for your B2B SaaS

🎯 The SaaS Use Case

You're building a B2B SaaS platform. Your customers (Client A, Client B) each have their own end-users who need to log in.

The problem: Supabase Auth is single-tenant by default. If john@example.com signs up on Client A, they can't sign up with the same email on Client B.

This demo shows the solution: Complete tenant isolation where the same email can have independent accounts across different tenants (your clients).

Example: Customer John logs into Client A's portal with john@example.com. The same John can also log into Client B's portal with john@example.com using a completely different password. These accounts are fully isolated — Client A never sees Client B's data.

✨ What This Demo Does

  • Same email, multiple tenants: Sign up with test@example.com on both Tenant A and Tenant B
  • Different passwords per tenant: Each tenant gets its own independent credentials
  • Two login methods: Email+Password or OTP (6-digit code via email)
  • Complete isolation: Accounts are fully separated - logging into Tenant A doesn't affect Tenant B

🚀 Try It Yourself

In this demo, you're a customer named John who needs accounts on two different SaaS clients. Sign up with the same email address on both tenants to see complete isolation in action:

💡 Test it: Use john@example.com on both clients with different passwords. You'll have two completely isolated accounts — logging into Client A has nothing to do with Client B!

🔧 How It Works

1️⃣
Internal email mapping: When you sign up with user@example.com on Tenant A, the backend generates a unique internal email like abc123...@customers.internal
2️⃣
Supabase creates the account: The internal email is used with Supabase Auth, so Supabase sees different emails for each tenant
3️⃣
Database stores the mapping: A PostgreSQL table maps real emails to internal emails per tenant, enabling true multi-tenancy
4️⃣
Email webhooks intercept messages: When Supabase sends emails, webhooks intercept them and forward to your real email address via Resend

📖 Get the Code

This is a complete, production-ready starter template. Clone it, configure your Supabase project, and deploy your own multi-tenant auth system.

View on GitHub