How can I allow tenants to choose from multiple website templates? #328
Replies: 1 comment
-
In case it helps anyone in the future, we opted to split each template into its own Next.js app inside a Turborepo, and use Vercel's ability to switch domains between projects as our customers switch templates. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is similar to #252 that @steven-tey helped with, but instead of needing unique CSS variables for a tenant within a single website template / Tailwind config, we need to support multiple website templates for tenants to choose from, and each template has its own Tailwind config.
We have an overly complex version of this working currently, where we lookup a domain's template ID in Vercel's edge config in middleware, and then route to
[domain]/template-1/[slug]
. From there, the template'slayout.js
file imports astyles.css
which in turn imports its owntailwind.config.js
. This works great but comes with the overhead of maintaining the edge config.What I'd really love to be able to do is simply route to
[domain]/[slug]
and have thelayout.js
fetch the template ID for the domain from our db, and then dynamically import the proper template's components and styles. In testing this approach, the template components import fine, but when they try to import theirstyles.css
it doesn't load the correct one.Not sure if this is a bug, or why it works in our current approach and not this preferred one. I put together a simple demo showing the preferred approach and the styles issue, and would really appreciate any guidance or suggestions.
Beta Was this translation helpful? Give feedback.
All reactions