color-mode icon indicating copy to clipboard operation
color-mode copied to clipboard

forced dark and light mode in 2 different projects

Open abolix opened this issue 6 months ago • 3 comments

Version

@nuxtjs/color-mode: 3.5.2 nuxt: 3.17.3

it's not really a big of a problem, just wanted to report to see if it's normal or not.

so I have 2 projects. one project is forced on light mode and the other is forced on dark mode, and I run these projects both on my localhost port 8000, as you might expect, when I run first project (forced dark), my local storage would be set to dark and when I turn off this project and run the second project (forced light), it's still gonna be dark, I have to manually delete the localstorage to fix the issue.

abolix avatar Jul 19 '25 05:07 abolix

The browser localStorage shares the same key-value across domains and subdomains, so the nuxt-color-mode localstorage key applies globally.

You can use the storageKey option in your nuxt.config.ts to set a unique localstorage key for nuxt-color-mode per project.

export default defineNuxtConfig({
  ...
  colorMode: {
    storageKey: 'nuxt-color-mode-app1' // change this per project
  }
})

harcop avatar Aug 05 '25 12:08 harcop

Cool ! but isn't it better that when we force a color mode and run the project, the code clears that storage ? my problem is solved but I think it would be a good update

abolix avatar Aug 06 '25 08:08 abolix

Cool ! but isn't it better that when we force a color mode and run the project, the code clears that storage ? my problem is solved but I think it would be a good update

Just ran into this. Thanks for the clarification. Agree with OP, would be nice to clear in dev server start

juane1000 avatar Sep 03 '25 01:09 juane1000