Skip to content

Color mode resets to light when opening new tabs (localStorage + SSR) #341

@Cody3395

Description

@Cody3395

Version

@nuxtjs/color-mode: ^4.0.0
nuxt: ^3.20.2

Reproduction Link

I will attach a screen recording showing the issue.
The bug can also be reproduced directly on https://nuxt.com (its built-in color-mode demo).

Steps to reproduce

  1. Use Nuxt 3 SSR with @nuxtjs/color-mode and storage: 'localStorage'.
  2. Switch theme from light → dark.
  3. Open any page link in a new tab (target="_blank").
  4. Repeat quickly by opening multiple links in new tabs in rapid succession.

What is Expected?

  • The new tab should load immediately with the correct theme (dark).
  • The value in localStorage should stay stable.
  • No flash or fallback to light mode should occur.

What is actually happening?

  • When opening a new tab, the theme briefly resets to light, then switches back to dark after hydration.
  • localStorage temporarily changes from "dark""light""dark" again.
  • When opening tabs quickly, the UI becomes visually inconsistent due to the flicker.

This issue also happens on https://nuxt.com, which indicates it is a general problem with @nuxtjs/color-mode using localStorage in SSR mode.

https://mork.ro/rCcYj#

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions