Hi. In the scenario I develop and sell 1-3 websites themes (Nextjs, Payload) to > 20 clients. Can I use a monorepo that contains all of the clients and can I deploy to Payload Cloud Pro and have the clients configure their DNS settings to point to the server? I have no experience with any of this, open to any suggestions that simplify the process.
The objective will be to scale to over 100 clients, so ideally the development caters to that from the start.
Any search terms you recommend for learning?
Totally! You can achieve multi-tenancy in Payload using role-based access control. There are many topics around this, a quick search using those keywords should get you pretty far. Essentially, you'd have an
or similar collection for each of your clients. Then, every piece of content is assigned to an organization using a basic relationship field. This way each time a request is made for content you check the content ownership and control access based on whether the user is a pat of that organization. Here are the docs around access control:https://payloadcms.com/docs/access-control/overview
. In your case though, you may want to take this a step further so that your access control also checks domain origins off the request.
As of today the "pro" plan only supports up to three custom domains, though. But you'll still be able to achieve your multi-tenancy setup just the same with the only exception being that the API url won't be unique across each client.
Thanks Jacob. In my case I want to create multiple themes for multiple tenants to select. These tenants have an existing domain, such as JohnDoe.com. Can they configure their DNS settings to point to the Payload server so they can keep their domain name? Does that require setting up a custom domain for each tenant via Payload to link to?
If their front-end is hosted elsewhere like Vercel, Netlify etc, you'd simply point their APIs to your single Payload server.
Ok great, thanks Jacob.
Hi @jacobsfletch . Can you please expand more on the setup. So I'd like to offer portfolio themes that the user can customize to their preferences, such as adding their portfolio items. Themes and layout blocks will initially be unchangeable - they can only select different themes for different styles and edit the content.
How might it work if there's only 1 server? Ideally I'd like to create auth to register them as a client with their name, which will then setup their own database, within my admin database that hosts all of the tenants?
I'm new to backend and only a few months in on front-end - trying to understand the logic to enable an automated system with little to no manual interference.
On a side topic - What boilerplate setup should I use for this project?
The database would be shared amongst the tenants with access control keeping the information separate. If it's a requirement to keep your client's data isolated than multi-tenancy might not be the right choice here. But there are many advantages to multi-tenancy, including simplifying your codebase and infrastructure. You could start off with the basic website template, it's not multi-tenancy but comes with basic role-based access control to get you up and runninghttps://github.com/payloadcms/template-website
. I'm going to be writing better docs for that template today so keep an eye out also.
One thing we definitely should do is make an official multi-tenancy example. This would be huge.
Thanks @jacobsfletch . Yea, that'll be great. I wonder what a popular topic is.... maybe e-commerce, so people can create marketplaces for strange niches, like renting out their swimming pool (that's actually a thing). Maybe you guys can do it using the snowplow app TRBL built.
I'll start off with the template and create the website as stand-alone and develop the multi-tenancy website if I get sales.
With the little bit of knowledge I have, I don't understand how I setup the users to have their own dashboard if they don't have their own URL and I can't access their domain? "To access their dashboard, the tenant simply navigates to their designated subdomain or URL and logs in with their username and password." Should they access my admin panel, register there as a tenant and that'll setup their own database to edit? I'll study that template now.
Either way, the URL is just a mask for your single instance of Payload. When users arrive, access control will determine what they can and cannot see and do. This can be based on user roles, website domains, etc. But the idea is that you haveone
running Payload server hostingmultiple
Makes sense, thanks Jacob.
Get help straight from the Payload team with an Enterprise License.