SSR issues with using UI frameworks in Next.js #73309
-
SummaryProblems encounteredWhen using some UI frameworks, when configuring dark mode, you need to nest a Provider in the top-level component, or use some reactive variables to switch dark mode. However, if 'use client' is used at the top level, all nested components will become client-side rendered. This also loses the meaning of SSR. Existing solutions (not ideal)
Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi @FerretAngel Can you tell us which UI framework are you using? (also good thing to provide some code snippets) For example, I'm using |
Beta Was this translation helpful? Give feedback.
Oh, there is a many ways to do that.
As example you can make a static layout for everything, and hide menu by default. For now you will have a static html version with links, which is fast and good for SEO.
Then make your client component (or service), which will find your button and attach click to it and make your actions.
Another trick is, you can pass part of server layout into client components:
And your client component make looks like this, and you can do whatever you want 😁