Back to Resources
SaaS Development7 min read

Handling User Signups for Multi-Tenant SaaS Apps in Bubble

Building a multi-tenant SaaS app in Bubble.io comes with unique challenges, especially when it comes to user management.

Building a multi-tenant SaaS app in Bubble.io comes with unique challenges, especially when it comes to user management. Two critical considerations for developers are:

  • Data Separation (Siloing): Ensuring that each tenant's data is securely separated to maintain privacy and security.
  • Unique User Signups Across Tenants: Enabling a single end-user to sign up with the same email address across multiple tenants.

In this blog post, we'll focus on the second challenge: how to enable a single user to sign up with the same email address for multiple tenants in your SaaS app, overcoming Bubble's built-in unique email validation.

The Problem

Bubble.io requires that email addresses in the Users table be unique. This creates a limitation for multi-tenant SaaS apps:

If a user tries to sign up with the same email address (e.g., username@domain.com) for multiple tenants, Bubble's validation rules will reject the sign-up.

Why might this happen? Well, let's say you build an auction platform where bidders buy from many different auctioneers all using the platform, then you need to enable users to register independently for each one.

The Solution: Modifying the Email Address

The key to solving this issue is to append a unique identifier to the email address before saving it in Bubble's database. This makes each email unique for Bubble while preserving the user's original email for communications.

Here's how you can implement this solution:

Step-by-Step Guide

1. User Enters Their Email

When a user signs up, they provide their email address (e.g., username@domain.com).

2. Generate a Unique Suffix

Create a unique identifier for the tenant, such as the tenant's ID, subdomain, or a random string. For example, if the tenant's ID is tenant123, the suffix will be tenant123.

3. Modify the Email Address

Append the unique suffix to the email address, using a format like tenantID+username@domain.com. For example:

tenant123+username@domain.com

4. Save the Modified Email

Store the modified email in Bubble's database. Since the email is now unique for each tenant, it won't conflict with Bubble's validation rules.

5. Retrieve the Original Email When Needed

Whenever you need the user's original email address for communications or other tasks, split the stored email at the + symbol and use the first part. For example, from tenant123+username@domain.com, extract username@domain.com.

Why This Works

This approach allows a single user to sign up with the same email address for multiple tenants, while maintaining the following benefits:

  • Bubble's Validation is Satisfied: The modified email ensures uniqueness in the Users table.
  • Original Email is Preserved: The original email is easily retrievable for communication purposes, ensuring consistency for the end-user.
  • Tenant-Specific Signups: Each tenant can have their own version of the user, linked through the modified email.

Example Use Case

Let's say you're building a project management SaaS app. A freelance designer (username@domain.com) works with two different clients using your platform. With this solution:

  • The designer signs up for Client A (Tenant ID: clientA) with the modified email clientA+username@domain.com.
  • They also sign up for Client B (Tenant ID: clientB) with the modified email clientB+username@domain.com.
  • Both clients can interact with the designer's account independently, while the designer receives consistent communications via username@domain.com.

Final Thoughts

Handling multi-tenant user signups in Bubble can be challenging, but with this email modification technique, you can ensure a seamless experience for both users and tenants, just by appending unique identifiers to email addresses.

Key Takeaways

  • Append tenant IDs to email addresses to enable unique signups across tenants
  • Use the format tenantID+username@domain.com to satisfy Bubble's unique validation
  • Extract original email by splitting at the + symbol for communications
  • Scales effortlessly across multiple clients while maintaining data separation

Need Help with Your Multi-Tenant SaaS App?

Building complex multi-tenant architectures requires expertise. Let's discuss how we can help you implement secure, scalable solutions for your Bubble.io SaaS platform.