persistedstate.ts 323 B

1234567891011
  1. import { createNuxtPersistedState } from 'pinia-plugin-persistedstate/nuxt'
  2. export default defineNuxtPlugin(nuxtApp => {
  3. const maxAge = 365*24*60*60;
  4. const expires = new Date(Date.now() + 1000*maxAge);
  5. nuxtApp.$pinia.use(createNuxtPersistedState(useCookie, {
  6. cookieOptions: {
  7. expires, maxAge
  8. }
  9. }))
  10. })