I built a web app with NextJS that I sell b2b, where users (my clients customers) can check in to a location. They provide their name and get a check in number. The app shows client related information (opening hours, address,…)
Second part of the app is an admin panel for my clients to login and see all names and check in numbers and can provide more information.
Currently I am in beta phase and my clients are friend‘s companies, but the app is scaling very well and I need a better approach than the following:
- my customer buys a VPS and a domain
- I install a LEMP stack
- I proxy the domain in nginx to localhost:3000
- I configure the database to store the customers
- I copy the root of my app to the server and run it (npm run build && npm run start)
I do this for every customer (currently 25). When there is a new customer, or an update of the app, it is hard manual work.
Very important is, that my clients customer don’t see that there are other companies using my app.
What I want to accomplish now is the following idea and I want to know of there is a better approach or if this is good practice:
- I want to scale to 500+ clients
- I use my own VPS
- Each client gets a subdomain of my own domain (this is okay for my clients)
- My clients don’t need extra servers anymore
- I create a table in my MySQL database with the client information (opening hours, address,…)
- In the Nextjs app I detect the subdomain and query my database
- I have one table for checked in customers related to the configuration table
- I start one instance of my app
- I locate all subdomains to that one instance
- My clients have one admin login screen and once logged in they load the data related to the login (using JWT so that clients can’t get data from other clients)
- For new customers I just add a new subdomain and one MySQL row and they are ready to go. This is easy to manage and if there is an update, I just update my one instance of the app.