Next.js Discord

Discord Forum

Is it possible to customize global.css theming with values fetched from database before first render

Unanswered
Ocicat posted this in #help-forum
Open in Discord
OcicatOP
I'm working on a white-label SaaS, and we want to allow merchants to customize the theme of the website. We're using App Router, and the merchant specific theming logic will be decided based on the domain of the request (all requests will ultimately be resolved by a single Next.js app, but it will appear to be multiple different products).

I'm building this with Tailwind, so I could accomplish this with css vars, but I don't think the proper theme would be available on the first render.

The standard approach would be to update the css vars through the document API, but this would only happen in client code.

Ideally, the server components have the correct theme on first render. Is this even possible?

0 Replies