Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage not found when using in nuxt environment #37

Open
mishka86 opened this issue Apr 14, 2022 · 1 comment
Open

Storage not found when using in nuxt environment #37

mishka86 opened this issue Apr 14, 2022 · 1 comment

Comments

@mishka86
Copy link

There is no problem when using the Basic Usage method.
When using separate storage(localStorage, sessionStorage) for strategies in Advanced Usage
I get an 'is not defined' error.
Do I need any special settings?

@LokiWasHere
Copy link

I encountered the same problem, to solve it while waiting for a patch, it is possible to add a condition on the storage process.client. That way, it will be ignored on the server-side.

Example of code:

// store/index.ts
export const useState = defineStore('keyValue', {
  // states & actions & getters
  // 
  // 
  // 
  persist: {
    enabled: true,
    strategies: [
      { key: "keyValue", storage: process.client ? sessionStorage : null },
    ]
  }

})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants