next-themes is a React theme abstraction for Next.js that helps you implement dark mode with a small setup. It supports system preference via prefers-color-scheme, prevents theme flashing on load (SSR and SSG), and can sync the active theme across tabs and windows using a ThemeProvider and a useTheme hook.
Project status
- The source appears actively maintained, with patch-level
updatesin late 2024 and early 2025, and an additional upstream push timestamp reported for 2026-02-25. - Apparent update cadence: several improvements landed in a short window in March 2025 (v0.4.5 on 2025-03-09, v0.4.6 on 2025-03-11), following a prior update in December 2024 (v0.4.4 on 2024-12-05), then a longer gap with no further versioned summaries shown.
AI summary generated Today
Recent updates
v0.4.6
3/11/2025This patch release primarily fixes a runtime edge case in the theme script update logic when the optional value mapping is missing or null. The code now guards access to value[theme] to prevent errors and visible flashing. A small packaging metadata change is also present in package.json.
v0.4.5
3/9/2025v0.4.5 updates how next-themes resolves and applies themes, and tweaks CI tooling. It maps theme values to class names correctly in the injected script and pre-computes the resolved theme to reduce extra renders. The release notes also mention updating Next.js and fixing corepack-related CI failures.
v0.4.4
12/5/2024Release v0.4.4 contains a fix aimed at preventing an infinite loop that could cause theme flickering. The code change specifically alters how the library responds to the browser "storage" event, plus a minor README link text change.
v0.4.3
11/4/2024v0.4.3 adds support for passing the provided `nonce` prop onto the inline style tag used by `disableTransitionOnChange` (to support stricter CSP configurations). The implementation also updates the effect to react to `nonce` changes, and the repo updates PostCSS from 8.4.28 to 8.4.31 in example projects and the lockfile.
Featuresv0.4.2
11/4/2024v0.4.2 primarily re-exports type definitions from the library entrypoint. The code diff also updates the example applications to use a newer Next.js version, which is not mentioned in the release notes.
Featuresv0.4.1
11/4/2024v0.4.1 adds support for multiple theme attributes in the injected inline script, and introduces a new `scriptProps` prop that lets users pass attributes to the injected `<script>` tag (for example to work with Cloudflare Rocket Loader). The release notes also include documentation updates for TailwindCSS >3.4.1 and a README snippet about dynamic client-side loading to avoid hydration mismatch.
Featuresv0.4.0
11/4/2024v0.4.0 refines next-themes' ThemeProvider behavior with improved inline script minification, fixes for typing and functional updates to setTheme, and adds support for multiple attributes. It also expands peer dependency support to include React 19.
Featuresv0.3.0
3/13/2024This release (v0.3.0) focuses on making next-themes consumable directly from React Client Components by adding a top-level "use client" directive. The code diff also includes broader refactors around types, testing/build tooling, and module packaging outputs.
BreakingFeaturesv0.2.0
5/5/2022v0.2.0 makes a small set of mildly breaking changes to how the library injects its script into the page. It also fixes multiple issues, including undefined references in the injected script, and restores compatibility with CSP nonces by no longer using base64-encoded script contents.
BreakingSecurity