pacocoursey / next-themes

Perfect Next.js dark mode in 2 lines of code. Support System preference and any other theme with no flashing
https://next-themes-example.vercel.app/
MIT License
4.86k stars 173 forks source link

Next Themes Flash of White BG when using the basePath #242

Open MaedahBatool opened 8 months ago

MaedahBatool commented 8 months ago

Hi folks, thanks for all the awesome work here.

I'm using the latest next-themes and next but getting a flash of white bg when loading the page for the first time only.

On the homepage there's no flash, but I'm using basePath: '/docs' if I go to localhost:3000/docs or even online in the live prod site, I see an issue only on the basePath URL — https://sourcegraph.com/docs — which makes me wonder if the basePath causes this issue. I have tried building and serving locally, same issue. Only happens on the basePath /docs and doesn't happen on localhost:300/

Help!

PixeledCode commented 8 months ago

For some reason, the dark class on HTML is being removed and added again during page load. You can notice this more easily if you throttle the load through the Network Tab. Probably implementation issue

jahirfiquitiva commented 7 months ago

@PixeledCode I'm seeing the same weird behavior 😕

JackNapolitano commented 7 months ago

as am I

trm217 commented 4 months ago

@MaedahBatool Did you manage to solve this issue? Page routing is not used anywhere in next-themes, so I doubt that it has anything to do with the setting. I would assume that the issue is that the loading of the script somehow is deferd.