Static GitHub Issues

[650] Window is not defined when store is activated

prev: Make context available on $nuxt
next: Access response to set cookie on server-side

Since window is not defined when store is activated, I don't see a way to refill the store from localStorage before any of the page components get loaded. Tried:

  • Creating store from a plugin and middleware
  • Directly writing to window.__NUXT__.state from a plugin
  • Waiting for window to load inside store/index.js

So, I ended up refilling the store from localStorage on mounted of one of the ~components/ Are there any ways of doing it?

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c561">#c561</a>)</em></sub></div>