Can You Really Build Multi-Tenant SaaS Apps in Bubble? (Yes, Here's How)

Dennis H. Lewis shows how to build multi-tenant SaaS apps in Bubble by creating sandboxed workspaces for each organization. You need a workspace table, privacy rules enforced before database queries, and the Coalias plugin for custom domains. Handle multi-workspace users with a switcher and build an invitation system during onboarding.
Chapters
In this video, I want to talk to you about creating multi-tenant applications and also answer the question, can you really build multi-tenant applications in Bubble? So first of all, we should talk about what is a multi-tenant application. So mostly these are B2B applications where you have multiple users sharing a common instance of your application. So, you know, you sign up Acme Corporation and they've got 10 employees using your application and each tenant needs to be sandboxed so that they can't ever access data that's outside their organization. So, are all SaaS applications multi-tenant? No, not really. Lots and lots of SaaS applications are just multi-user, and a multi-tenant application usually means you're going to have, you know, an organization, what I like to call a workspace. And the key things we've got to take into account when we're building a multi-tenant application are the database design. So that means you're going to need a workspace table. We're going to call it workspace. And then in your user table, or we usually use what we call a persona table, because I always recommend that you don't just overload your user table with lots of data because it's being pulled in on every page load. So you want to keep it as lean as possible. So We use a Saddlebag table called a persona, and each persona's going to have their current workspace, and that's going to be kind of what you use to control so that you're keeping everything isolated. So, the key ingredient here is going to be your privacy rules. So, you're going to need to be really careful about incorporating the workspace into all of your privacy rules. Why do I say that? Because privacy rules execute in Bubble before any database searches. So that is the surefire way to make sure that one user in one workspace is not able to break through the barrier and, you know, see information from another workspace. So you're going to want to look at the per— the users or the personas' current workspace, and you're going to want to make sure that's in the privacy rules. But for that to work, You also need to make sure that you've included a workspace field in all of your important tables. Okay. And it may not be all of your tables because there may be a few tables that are application-wide. Okay. But almost any table that is utilized by your users is going to need a workplace field in it so that you can build the privacy rule around that field. And that's what we call a sandbox where, you know, nothing outside this workspace is ever visible to other users. There are a couple of thoughts there that you may have to take into account, and it's good to do this at the beginning in your database design is, are you going to allow users access to multiple workspaces? If so, then you're going to need to develop some sort of a workspace switcher so that they can switch between workspaces. It can also be revenue driving because sometimes, you know, a business owner will have 2 businesses and they want to have, you know, 2 workspaces on your application that are completely separate because the employees are separate, but the owner's gonna want to be able to go into both. So you're gonna wanna be able to switch. The executives of the main business can see across all the business units, but each business unit is a separate workspace. And you can charge separately for multiple workspaces. And that opens the door later to thinking of things like workspace consolidation, where you give certain users the ability to see across multiple workspaces that they have access to. And that does complicate your privacy rules more. You're going to have to be a lot more careful. I'd recommend that you Get in touch with us, but it is doable as well. The next biggest hurdle that a lot of people talk about when they're talking about multi-tenant applications is if you want to create custom domains or custom subdomains for each workspace. So for example, if we wanted to have for our new Conjuro app, we wanted to have ratio.conjuro.app or circles.conjuro.app, or give your users a custom subdomain for their instance of the application. There isn't a simple native Bubble way to do that. And if you go Googling and YouTubing out there, you're gonna find a gazillion dead ends out there that are gonna take you here and there. But But it can be done. The key here is to use a system and a plugin called Coalias. It's coalias.com. Really cool plugin and system that will allow you to automatically from your Bubble application, from a workflow, create a subdomain that points to a specific page in your or in your Bubble application and you know passing it through a specific. Page domain, you can do all sorts of things. It does get a little bit technical. So if you have any doubts, you know, first of all, reach out to the people at Coalesce. They're really good people there. They've got good support. But if you get stuck, feel free to reach out to us here at ratio.dev. We can help you with that as well. Finally, a couple of things to keep in mind. When you're setting up multi-tenant, you're going to want to think about the considerations that has with onboarding. Because now when you onboard a user, you need to assign them to a workspace. So the first person who signs up, you need to create that workspace. And that will also often require, you know, populating different tables in your applications so that they're not starting off from scratch. But then the admins or the owners of that workspace need to be able to incorporate more users. And so there you're going to need to create an invite system so that users are automatically added to the right workspace when they sign up. I think the overall message here is that building multi-tenant applications in Bubble is perfectly doable. You can provide a seamless experience for your users, and it can be secure and scalable. You just need to be sure you do it right. So hopefully you enjoyed this video. If you have, give it a like. A thumbs up, subscribe to our channel. That means a lot to us. And if you have any doubts or questions, feel free to leave a comment in the comment section or reach out to us at ratio.dev. We'll be glad to talk to you. You know, come check out our school community. There's a link in the description for that as well.
More from Dennis

Is Google Killing Websites? The Future of Search, SEO & Web Design After Google I/O

Something we're still looking forward to in Bubble: richer design experiences! #bubble #nocode #ai

Big mistake companies are making right now: firing employees instead of empowering them. #ai







