DEV Community

Cover image for Better Themes: A Zero-Flash Theme Provider for React
jQueryScript
jQueryScript

Posted on

Better Themes: A Zero-Flash Theme Provider for React

better-themes: a React library that handles theme switching without the usual SSR headaches.

It blocks rendering until the theme loads so you never see that flash of white before dark mode kicks in.

Works with localStorage for cross-tab sync or sessionStorage if you want isolation.

The library detects system preferences automatically and applies them through class names or data attributes.

Key features:

  • Zero flash on page load
  • System preference detection
  • Works with Next.js App Router and Remix
  • Full TypeScript support
  • Tailwind CSS compatible

πŸ‘‰ Blog Post

πŸ‘‰ GitHub Repo

πŸ‘‰ Live Demo

Top comments (0)