How to build multi-tenancy? #495
-
Hey, I was reading about multi-tenancy here Also, I read here in different ways to add multi-tenancy support. I want to go for the "one schema per tenant" solution but using Vendure as my backend. Does anyone have any library in mind similar to django-tenants to add multi-vendor support? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 20 replies
-
Hi there, I skimmed the article you linked but I don't really understand what is meant by "one schema per tenant", but it seems it may be a Postgres-specific solution? Vendure supports several different DBs so I doubt any DB-level solution would work here. By "community projects" it is referring to contributions to the core that enable multi-tenancy features, rather than a plugin you can install. For example: These PRs make it so Orders and Customers are assigned to specific channels. So as of now the following entities are "channel-aware":
A Channel in this case can be used to represent a tenant (vendor). So currently it may be possible to have a multi-tenant solution, but I'm pretty sure you'll find some rough edges and cases where things may break down or not be as expected. Alternative solutionIf you are aiming to build a Shopify-like platform where a merchant can create an account and then get a new e-commerce store created for him or her, then there is another approach you may want to consider. You can do it at the operations level by creating infrastructure that will create a new Vendure instance for each tenant. In this way each instance is truly isolated. Pros:
Cons:
|
Beta Was this translation helpful? Give feedback.
-
@michaelbromley
To implement this I'm thinking of creating a new channel every time a new user comes in and creates a new channel page. I hope this approach would be fine? |
Beta Was this translation helpful? Give feedback.
-
Good Morning Michael I was trying to figure out the right way to use a channel with Nextjs Dyanmic routing. I want to achieve the following with graphql, nextjs and urql SSR
SSR is setup by following the guide https://formidable.com/open-source/urql/docs/advanced/server-side-rendering/#nextjs / pages/index.js
import React from 'react';
import Head from 'next/head';
import { withUrqlClient } from 'next-urql';
const Index = () => {
const [result] = useQuery({
query: '{ test }',
});
// ...
};
// was wondering if I could add the store-name to the url below
export default withUrqlClient((_ssrExchange, ctx) => ({
// ...add your Client options here
url: 'http://localhost:3000/graphql',
}))(Index); I asked this question in the Urql, their solution works but they also suggested to use a better method to do the same So now i'm thinking to use the channel token as a query parameter, but I cant figure out where exactly shall the query parameter go? The options in any of the queries does not seem to have a channel token parameter. |
Beta Was this translation helpful? Give feedback.
-
Hello ; |
Beta Was this translation helpful? Give feedback.
Hi there,
I skimmed the article you linked but I don't really understand what is meant by "one schema per tenant", but it seems it may be a Postgres-specific solution? Vendure supports several different DBs so I doubt any DB-level solution would work here.
By "community projects" it is referring to contributions to the core that enable multi-tenancy features, rather than a plugin you can install. For example:
These PRs make it so Orders and Customers are assigned to specific channels. So as of now the following entities are "channel-aware":
A Channel in this case c…