NotesBuddy icon indicating copy to clipboard operation
NotesBuddy copied to clipboard

fix: prevent dark theme flash

Open KartikXx opened this issue 6 months ago • 0 comments

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 beforeInteractive script strategy.
  • Used the same notes-buddy-theme key in the init script and theme provider.
  • Handled dark, light, and system themes consistently.
  • Updated color-scheme so 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 --check passed.

KartikXx avatar May 16 '26 06:05 KartikXx