Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose CSS variables to avoid FOUC during SSR #149

Open
jpdriver opened this issue May 9, 2022 · 3 comments
Open

expose CSS variables to avoid FOUC during SSR #149

jpdriver opened this issue May 9, 2022 · 3 comments
Assignees

Comments

@jpdriver
Copy link
Contributor

jpdriver commented May 9, 2022

Context:

Useful info:

@carbonrobot
Copy link
Contributor

Closing as SSR is now supported

@slorber
Copy link
Contributor

slorber commented Dec 12, 2024

@carbonrobot I looked at the PR and I'm not 100% sure this is solved.

SSR has never been the problem. We use this package in Docusaurus to render things at build time. Client components are still SSRed, and can use client-side hooks, unlike RSCs.

Removing client-side hooks only unlocks RSCs. SSR has always been supported, and the FOUC issue is probably still there. I don't see any alternative to using CSS env variables for styling tokens instead of using hardcoded colors.

The only case I can see where this would be solved is when the dark/light mode is stored in a cookie and where the SSR server is able to read it. But the color scheme is more likely to be stored in localStorage in many apps, and when using SSG, there's no cookie available at all at build time.

@carbonrobot
Copy link
Contributor

@slorber Thanks, you are correct I may have closed this one prematurely.

I'm not sure a fix is possible for the dark/light mode FOUC. As you correctly pointed out we don't have that information available during SSR in order to know which mode to render. Any method to determine it would be dependent on the meta framework and any cache strategy used.

I will try to revisit the linked PR approach and see if its still the path forward.

@carbonrobot carbonrobot reopened this Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants