# next-themes: handle themes without flashes or hydration pitfalls

Canonical source : [next-themes: handle themes without flashes or hydration pitfalls](<https://sebastien.rigaux.be/en/tech-watch/links/next-themes-handle-themes-without-flashes-or-hydration-pitfalls>)

next-themes applies the theme as the page loads, respects the system preference, and syncs the choice across tabs. Its `ThemeProvider` works with both the App Router and `pages/`, while a hook lets components switch themes or handle multiple variants.

One architectural detail matters: the browser-stored theme is unavailable during server rendering. UI that depends on `useTheme` should wait until the client component mounts to avoid hydration errors. The library also updates the `<html>` attribute—`suppressHydrationWarning` is recommended—and remains independent of the CSS solution in use.

- Selected on : 2026-10-29

- Entry updated : 2026-11-07T20:32:37+0000

- Format : Tool

- Source language : EN

Original resource : [next-themes: handle themes without flashes or hydration pitfalls](<https://github.com/pacocoursey/next-themes#readme>)

Tags : [Next.js](<https://sebastien.rigaux.be/en/tech-watch/tags/nextjs>) · [React](<https://sebastien.rigaux.be/en/tech-watch/tags/react>) · [Hydration](<https://sebastien.rigaux.be/en/tech-watch/tags/hydration>) · [SSR](<https://sebastien.rigaux.be/en/tech-watch/tags/ssr>) · [UI/UX](<https://sebastien.rigaux.be/en/tech-watch/tags/ui-ux>)

Available versions : [Français](<https://sebastien.rigaux.be/veille/liens/next-themes-gerer-les-themes-sans-flash-ni-piege-dhydratation>) · [English](<https://sebastien.rigaux.be/en/tech-watch/links/next-themes-handle-themes-without-flashes-or-hydration-pitfalls>)

[Back to tech watch](<https://sebastien.rigaux.be/en/tech-watch>)
