How to achieve multitenancy in Directus
HTML-код
- Опубликовано: 7 фев 2025
- Directus is a super powerful data platform, and as you work with it more it's true power can be realized. In Short Hops, our team provide quick insights in how to get the most from Directus.
More episodes on Directus TV: directus.io/tv...
Nice content! I was just working on a multi-tenancy implementation these days, and I applied it just that way. The only issue is that I changed the "ownership" of the created item a bit so that it simply saves the tenant ID at the time of creation, because I add the tenant_id for all the items created, that way the tenant_id is immutable even if there are changes in the tenants of the users who created it
Great content again, thanks. Btw what is you software of choice you use to record?
Great question. We use a few different tools but for most screen recording style videos like this I'm using ScreenFlow.
--- Bryant
great to see a video on this - could be useful to add a deeper dive to help identify different cases... such as when users belong to multiple tenants and/or multiple roles - useful for SaaS community where a user can admin multiple brands with different roles in each.
Great suggestion! Are you building something like that now?
@@DirectusVideos We are building an app which needed this (ability to belong to multiple tenants with different permissions, think "GitHub organizations"). Unfortunately, it was too convoluted for me to attempt in production.
I would love to see on how to use directus with several languages for the content
Yes! Multilingual content tutorials are coming to our docs soon
How would someone have each “tenant” be able to run its own flows
That's truly awesome
Thanks!
How to handle authentication e-mails. Is it currently possible to isolate custom auth emails for each client? lets say I make a PIM software with multiple clients below. having my customers logging in inside directus and their webshop clients on the webshop frontend. Will it be possible to create an email templates customized for each customer in this setup.
Would it be possible to isolate the object storage elements images and files from one tenant to another? Kindly let me know.
Impresive! I'm thinking about change Laravel for directus to create my back-ends projects.
Is it possible to show the Team Name instead of the GUID within the Tasks Collection page?
Yes! You can use a display template for this -> docs.directus.io/user-guide/content-module/display-templates.html#display-templates
Nice video, thanks. Would it be possible to automatically populate the team field on the task for the user at creation time, so the user won't have to manually enter it, or could be possible to doit with flow? how to get the teams id using "{{ $accountability }}". Thanks!
Great. I need to develop a SaaS, do you think Directus would be a good option?
Like a lot of questions in development, the answer is... it depends...on the specifics.
But in general, Directus can be a great platform for building a SaaS because it provides a lot of functionality out of the box that you'd have to otherwise build yourself like - authentication, user roles and permissions, REST and GraphQL APIs.
How do i use tenancy in global presets (bookmarks)?
So, would I have to add the tenant ID to all tables? Like... if I had a separate table for phones, would I also have to add it so that other tenants couldn't see it? Wouldn't it be possible to add something like "users.phone" or similar?
Yes - you would add the tenant relationship to all the collections that are scoped to that tenant model.
For junction collections, it's probably more of a personal decision whether you want to add them there or not, depending on what data you're storing in the junction collection itself.
Interesting, but what about handling multilple webdesign clients on one tenant where each client has his own CMS ? Is this possible with directus?
You can give them all access to the same data studio instance and manage what they can see and edit with permissions.
This is a necessity to build a marketplace.
Please adjust the layouts of your videos, no need for this fancy background on the side and rather zoom in on the content
What if the task is shared between multiple teams?
Then you’d be setting up permissions differently but that’s entirely possible. Each task’s ownership would be a M2M and the permissions would look for one of them to match
That is not a very scaleable method for a multi-tenant setup, and a generally piss-poor way to do it.
How would you go about it? Subdomains so each tenant is isolated? Thats kinda what I am thinking but I am new to the concept of multi-tenant services like this
curious about this too? What is the not so piss-poor way
@@sheldonfourie5959 Every tenant having their own schema! You know, the way real multi-tenant apps do it.