Multi tenancy best practices #20841
Replies: 10 comments 41 replies
-
I feel @leerob approach does work well. It allows full control but does feel like more could be done to make this a better setup. It would be really nice to see something like the internationalisation setup where it can be configured and done at build time with incremental updates in live. The biggest thing missing for me now is static generation of variations of the same page. e.g. /about could have 4 different versions dependant on the brand |
Beta Was this translation helpful? Give feedback.
-
Update: we recently launched the Platforms Starter Kit that's a comprehensive template for building multi-tenant applications with built-in custom domains support + ISR. We also removed the 50 custom domain limit for all Pro teams on Vercel. We are working on providing a high-quality solution for multi-tenant applications, similar to Next.js Commerce for e-commerce 😄 🔜 |
Beta Was this translation helpful? Give feedback.
-
@eric-burel this discussion inspired me to solve one of the use-case that I faced during the work. Thanks to @leerob approach, I was able to run more than 100+ static website using this approach using single next.js server. Here is a case-study for the same. https://blog.smallcase.com/scaling-microsite-with-next-js/. |
Beta Was this translation helpful? Give feedback.
-
I ran into this problem myself and ended up building spinoff project to solve it called AppMasker. I’m happy to talk through it with anyone who’s struggling with multi-tenancy / whitelabeling / custom domains. |
Beta Was this translation helpful? Give feedback.
-
Hi guys, since the introduction of middlewares, it's waaay easier to setup multi-tenancy based on cookies, without having to alter the URL. You can also combine this with other related problematics, like the ability to customize the application per user (theming, AB testing), i18n redirections (advanced usages where you handle the redirections manually), handling paid content... I've wrote an article about how to cleanly handle the route params and rewrites to get the behavior you want. It includes a link to a code demo : https://blog.vulcanjs.org/render-anything-statically-with-next-js-and-the-megaparam-4039e66ffde It renders statically, and can fallback to per-request SSR if needed (eg adding a new tenant without having rebuilt the app yet). It can probably work with ISR even though I haven't tested it yet. It doesn't bloat the URL either, thanks to rewrites. You have full control on the setup. Link to the code: https://github1s.com/VulcanJS/vulcan-next/blob/devel/src/pages/vn/examples/[M]/megaparam-demo.tsx |
Beta Was this translation helpful? Give feedback.
-
Update: we recently launched the Platforms Starter Kit that's a comprehensive template for building multi-tenant applications with built-in custom domains support + ISR. We also removed the 50 custom domain limit for all Pro teams on Vercel. Hey everyone! We recently rolled out a simple example that allows you to create unique content pages with a multi-tenant infrastructure using edge function rewrites and ISR. Each of your users gets assigned a unique subdomain when they create their account, with the (usually paid) option to add a custom domain. |
Beta Was this translation helpful? Give feedback.
-
Has anyone able to implement this with a Next Frontend and Node Backend because I really need help, cause I'm on a deadline |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, I came across this post after doing some google, because i'm looking for a solution on a project i'm working on right now. Let me try to explain a bit on what we are working on right now. We are rebuilding our CMS that it can serve as API, and we want to use NextJS for our frontend framework to build the website with. Now at this point we have a so-called SaaS website, in the old way with PHP / HTML / CSS / Jqeury. This SaaS project is just one project that has multiple websites in it, that all share the same views with only a bit custom css and their variables to style it to their colors. This way we can manage them all, with just changing one view. We are now looking for a sulution for this, but then with NextJS. So what we are looking for is a solution to have multiple websites into our NextJS app. Where we would love to have just 'one' website that serve the views for all the website, and some way to change colors based on the website that is being visited. After some Google, i've seen solution that serve a Multi-tenant App (thins like Krabs.js). The only downside for us right there is that every website will have their own files, which means that if there ever changes something, we need to do this X amount of times for every website. This is something i've not found yet and really hope that someone here might read this and that knows how to or has an example how to get this working. What we 'just' need is like a .config file where we can add custom auth info for the website to talk with our API and a way to set custom variable colors. Things like Krab.js really comes close, but it's just missing that little bit that we really need. Also to reminder, this is the 1st time i work on a react/nextjs app, so it's kinda new for me, but from reading it sounds like that the middleware COULD do this all, i just don't really know how this would be possible. If anyone reads all this, and knows something, please hit me up. edit: To add a bit more, every website has their own unique domain, so it's not on subdomain level, and we will serve them on our own servers, not on Vercel |
Beta Was this translation helpful? Give feedback.
-
Can someone please give detailed instructions on how this is done? For instance: Step 1: Do this This way, we don't have to keep clicking on these links to articles that are either outdated, or written in a vague manner. Please help. You will be doing the community a huge solid. Thanks, |
Beta Was this translation helpful? Give feedback.
-
The approche i took is to define a template that groups multiple website And for the file structure it's like this /T1.. Then using the middleware i get the domain name map it to the template name using Redist then rewrite the request to /domainName/templates/templatename To prevent using Redist multiple time i stores the template name in the cookie and return it back to the client The problems of this method are |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
Writing multi-tenancy application can require some thoughts. I open this discussion so we can discuss the best practices.
I am currently implementing multi-tenancy with the following constraints:
I don't use server-side rendering, but I'd like to keep enjoying static site generation to render an application shell, like Vercel's dashboard is doing. Concrete example: you open "myapp.com/data", it renders a pages skeleton, it triggers a query to get the currentUser, it fills the page when we get the current user.
I am not sure this pattern will scale to multi-tenancy, but that's where I start.
This discussion is a bit beyond the scope of Next btw, I have a similar task to get done for a Meteor application.
Is anyone implementing something similar right now? Are there learnings to share?
Relevant resources
Open questions
Beta Was this translation helpful? Give feedback.
All reactions