Next.js Discord

Discord Forum

Multitenant Component Overwrite

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
I’m self-hosting a Next.js app using ISR because SSR just kills the server and I barely get 40rps on the home page .
The route structure is as follows [tenant]/[locale]/route.
Each tenant can overwrite any component , registry-based: shared defaults and tenant-specific maps.
The components that have overwrites are imported via dynamic imports in a client component that gets the tenant from a context.

The problem that we have is that the components are not in the initial page source so we have a content flash until the JS executes.
Is there a way to do this on the server so we prevent the flash? Or maybe since we know the tenant in the main layout make it so all components under the layout import from the specific component?

The only solution that i can think of is having separate deploys for all tenants with the tenant in the env so we can determine at build time all the imports but we need a single app to serve all clients

0 Replies