Comments (6)
But this will not affect its normal operation. There is data in the cookie
from pinia-plugin-persistedstate.
If I rename the plugins
to .client.ts
, let it run on the client, there will be no such error, and everything will become normal again.
from pinia-plugin-persistedstate.
Ok, with the latest createPersistedState
factory function introduced in v1.4.0, I managed to have everything fully functional with useCookie
even on server side.
plugins/persistedstate.ts
import { createPersistedState } from 'pinia-plugin-persistedstate'
import { defineNuxtPlugin, useCookie } from '#app'
export default defineNuxtPlugin(nuxtApp => {
nuxtApp.$pinia.use(createPersistedState({
storage: {
getItem: key => {
return useCookie(key, { encode: (x: any) => x, decode: (x: any) => x })
.value
},
setItem: (key, value) => {
useCookie(key, { encode: (x: any) => x, decode: (x: any) => x }).value =
value
},
},
}))
})
stores/user.ts
import { defineStore } from 'pinia'
export const useUserStore = defineStore('user', {
state: () => ({
username: 'PraZ',
}),
persist: true
})
@waset tell me if that fixes it for you as well, and I will update the Nuxt usage docs anyways. I may work later on a createNuxtPersistedState
helper anyway to make things more simple.
from pinia-plugin-persistedstate.
Mmh, indeed, I didn't get this error before.
The issue with adding .client
is that the plugin won't be run during server-side rendering.
I don't have an idea on what is actually causing that tbh.
If anyone has an idea, feel free to help. 🥺
from pinia-plugin-persistedstate.
Feel free to reopen if you still encounter an issue (with 1.5.0 once released)
from pinia-plugin-persistedstate.
It's so cool that it can be run
and bulid
.
Praise the function of this factory. I'm such a lazy person. I need public configuration too much.
from pinia-plugin-persistedstate.
Related Issues (20)
- How to handle this warning? Inconsistent rendering between server and client HOT 3
- reactive([1]) Unable to deserialize properly HOT 2
- Save to store after X seconds of no further changes. HOT 1
- Having interval inside a persistent store breaks persisting
- [pinia-plugin-persistedstate] Error: [nuxt] A composable that requires access to the Nuxt instance was called outside of a plugin HOT 2
- In the cookie store defineNuxtRouteMiddleware method was used in nuxt3 unable to get to the store of value HOT 3
- Critical security vulnerability? HOT 6
- nuxt bug Cannot read properties of undefined (reading 'sessionStorage') HOT 1
- Automatically set `Vary: Cookie` response header in Nuxt SSR
- pinia.use(piniaPersist) in a separate file, causing local storage to fail HOT 2
- Missing "./package.json" export HOT 1
- Not effective when working with vee-validate
- Global `cookieOptions` are not applied in Nuxt 3 HOT 1
- Type safe persist paths HOT 2
- Store not hydrated from cookies when used with `@nuxtjs/i18n` and `routeRules`
- Using store outside setup(), state persistence is not possible HOT 1
- The type of map print in console.log (typeof this.userMap) is object HOT 1
- Persist for "composition api" style HOT 1
- 配置 storage: persistedState.sessionStorage 会导致 v-bind 失效
- Vue: Argument of type HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pinia-plugin-persistedstate.