NotesBuddy
NotesBuddy copied to clipboard
fix: prevent dark theme flash
Summary
Fixes the white flash users see when dark mode is enabled and they navigate between pages.
The issue happened because the early theme script was reading localStorage.theme, while the app actually saves the theme under notes-buddy-theme. Because of that mismatch, pages could render light first and switch to dark after hydration.
What changed
- Applied the saved theme before first paint using Next's
beforeInteractivescript strategy. - Used the same
notes-buddy-themekey in the init script and theme provider. - Handled
dark,light, andsystemthemes consistently. - Updated
color-schemeso browser-native UI matches the active theme. - Prevented the provider from briefly falling back to light mode after hydration.
- Made the theme toggle a proper accessible button.
Validation
git diff --checkpassed.