Pinia its not showing my store
I'm using nuxt 3 and I want to persist the pinia store data when switching pages with SSr, I installed pinia-plugin-persistedstate but I don't know how to register this plugin in the application, can someone help me?
21 Replies
Where are you using the store?
Also no need to persist between pages
wow worked
This would be for reloading the page or reopening. It would read from the defined store. Default is cookies
to show i need to to put on setup, for example login.vue
π§
There is no need to persist
One thing I noticed, when persisting it removes it from devtools and keeps it by default in cookies
Why are you persisting in the first place ?
i need to persist data to manage authenticates routes
i need to check getter
You could just store the token in a cookie or localstorage yourself
logged
No need for a plugin
yes, but i could to created a getter logged to show true or false
what do you mean, pinia?
But you dont wanna store the whole user in a cookie
You would only store a token
im not storing whole user
im storing only token and setting a getter
Look at the useCookie composable from nuxt
There is no need for a store
showing cookies, my pinia data its encoded
Username john doe is encoded? π
Check the useCookie composable and use that to store and read a cookie
The store is not necessary
so i could just use usecookie?
@Likonima
I'm coming to vue2 and there we had the mixins that were shared throughout the application, I don't want to instruct usecookies all the time and get this data. I wanted to create a looged: true or false mixin based on this cookie, is it possible?
yeah i see
you still have to call the store though
you can do that without the persisted plugin though and directly use the composable in the store
how could i do that, would i create a composable/auth.ts and create a useState?
i have this composabled auth.ts but im getting usecookies its no defined