Next.js Discord

Discord Forum

Query related to make a multi tenant application using Next.JS

Answered
Skipjack tuna posted this in #help-forum
Open in Discord
Skipjack tunaOP
Actually I am trying to make an application provide an automated billing solution for some kind of services which the tenants will sell, My approach is to make an application on the web with the help of vercel and nextjs where there will be tenants who will buy our premium/membership from the parent site and they will greeted with their own site (tenant site) with their own landing page, own billing solution, own product page which will be customizable by the tenant and etc.

# My question is as follows.
1. Which kind of backend should i go for (for example which database, or show i make one custom server, which technologies i needed)
2. How will i test the multi-tenancy in localhost
3. Is this a bad idea? Any another approach is welcome.
Answered by B33fb0n3
1. I like to use postgres on a self hosted server (I use the server from netcup. They are pretty cheap, but have power).
2. The multi tenancy is just made though a correct middleware. So you can also test it via app.localhost:3000 instead of localhost:3000. So you can just add subdomains and it still works. An example [is here](https://github.com/vercel/platforms/blob/main/middleware.ts)
3. Multi tenancy sounds great 👍
View full answer

7 Replies

1. I like to use postgres on a self hosted server (I use the server from netcup. They are pretty cheap, but have power).
2. The multi tenancy is just made though a correct middleware. So you can also test it via app.localhost:3000 instead of localhost:3000. So you can just add subdomains and it still works. An example [is here](https://github.com/vercel/platforms/blob/main/middleware.ts)
3. Multi tenancy sounds great 👍
Answer
Skipjack tunaOP
4. What about authentication? That seem a though topic cuz every tenant will have separate authentication wheter they like to enable or disable on as of their own choices?
authentication is never easy, multi-tenant or not.

but it should be almost the same between a normal site and a multi tenant site. the only difference i can think of is that you need to set the cookie to the correct domain.

never implemented auth in a multi tenant app before so cant help much in this area.
@Skipjack tunasolved?