Dark mode sounds simple until you implement it. Then you discover the flash.
On first load, before JavaScript runs, your page renders with the default theme. Then the theme switcher kicks in. For a fraction of a second — sometimes longer on slow connections — users see the wrong theme before it corrects itself.
This is the flash of unstyled content (FOUC) applied to theming, and it's one of the more annoying UX problems to solve correctly in Next.js App Router.
Here's the approach that works, which I used building the theming system for a free AI image generation tool.
Why the Flash Happens






