DEV Community

Discussion on: 🌙 How I set Dark Mode for Gatsby website

Collapse
 
alexr89 profile image
Alex

Hey,

Sorry for being quite vague but do you know how to get something like this working using next?

I have it all set up and working, however there is a flicker if you select a dark theme and then refresh the page. The reason for this is because the _app.js initial state is "light", meaning that it sets the light theme, then checks the local storage - finds the theme entry - and sets the theme dark.

So essentially afaik it goes: renders on server -> sends over light theme -> checks local storage and finds dark theme -> renders dark theme

I don't know how to get around this issue, other than blocking the entire render of the app while we check local storage for a theme?