question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to persist state ^1.6.1

See original GitHub issue

HI, I have created fresh Nuxt 3 project with these dependencies. "devDependencies": { "@nuxt/content": "^2.0.1", "nuxt": "3.0.0-rc.4", "tailwindcss": "^3.1.6" }, "dependencies": { "@heroicons/vue": "^1.0.6", "@nuxt/types": "^2.15.8", "@nuxt/typescript-build": "^2.1.0", "@pinia/nuxt": "^0.2.0", "pinia": "^2.0.15", "pinia-plugin-persistedstate": "^1.6.1" }

this is a plugin that I have followed by .md instructions for Nuxt. import { createNuxtPersistedState } from 'pinia-plugin-persistedstate' import { defineNuxtPlugin, useCookie } from '#app' export default defineNuxtPlugin(nuxtApp => { nuxtApp.$pinia.use(createNuxtPersistedState(useCookie)) })

this is my nuxt.config.ts modules: ['@pinia/nuxt', '@nuxt/content'], plugins: [ {src: '~/plugins/pinia-persisted.client.ts', mode: 'client'} ]

this is my state/index.ts import { defineStore } from 'pinia' export const useFiltersStore = defineStore('my-store', () => { const counter = ref<number>(0); return { counter } },{ persist: true })

Can you point out if I made some mistake or if I am missing something? I have no errors with pinia, state is working as expected just I am unable to have persisted state for ‘my-state’.

Thank you!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ASoldocommented, Jul 15, 2022

AAA JUUU! It works! You saved me from a lot of trouble. Thank you so much!

1reaction
prazdevscommented, Jul 14, 2022

Ok, so if you use the latest versions of nuxt (rc-5), @pinia/nuxt (0.3.0) and pinia (2.0.16), and use the config given in https://github.com/prazdevs/pinia-plugin-persistedstate/tree/main/examples/nuxt i think if should work ?

side notes:

  • in nuxt.config.ts, don’t use buildModules but use modules instead.
  • dont declare plugins in nuxt.config.ts
  • you can declare the persistedstate plugin without .client is you use the helper with useCookie.

oh, and i had no idea there was a ‘pinia-plugin-persistedstate-2’ 😂 not mine so i can’t help with it 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

State not retaining when the App reload/Kill the App ... - GitHub
I am using redux for maintaining the state in my App, ... am using the below dependencies "@react-native-community/async-storage": "^1.6.1", ...
Read more >
Unable to resolve path to module 'react'. (import/no-unresolved)
I installed react and react-dom using npm i -E react react-dom trying to install the exact version which didn't install it correctly. npm...
Read more >
Invalid Pre-Release Train. The tra… | Apple Developer Forums
I'm here because I can't change a keyword on the store listing without a complete rebuild. Haven't seen a development process as frustrating...
Read more >
Wine Announcement - The Wine maintenance release 1.6.1 is ...
Bugs fixed in 1.6.1 (total 58): 2770 Powerbullet Presenter 1.44: ... the signaled/satisfied object functions. server: Store abandoned state as a flag in...
Read more >
Fix list for IBM WebSphere Application Server V8.5
IBM WebSphere Application Server provides periodic fixes for the base and Network Deployment editions of release V8.5. The following is a complete listing ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found