prazdevs/pinia-plugin-persistedstate

💾 Configurable persistence and rehydration of Pinia stores

TypeScript

2,513

468 commits

updated Aug 31, 2025

See the code

README

[!IMPORTANT] This project has a new home at codeberg.org/praz/pinia-plugin-persistedstate.
Everything (issues included) has been migrated and development/maintenance will continue over there.

pinia-plugin-persistedstate

npm version bundle size license

Configurable persistence and rehydration of Pinia stores.

Read the full documentation

Features

  • Persist Pinia stores with a friendly API inspired by vuex-persistedstate.
  • Highly customizable (storage, serializer, paths picking/omitting).
  • Out of the box SSR-friendly support for Nuxt.
  • Very smol (<2kB minzipped).

Quickstart

  1. Install with your favorite package manager:

    • pnpm : pnpm add pinia-plugin-persistedstate
    • npm : npm i pinia-plugin-persistedstate
    • yarn : yarn add pinia-plugin-persistedstate
  2. Add the plugin to pinia:

import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
  1. Add the persist option to the store you want to be persisted:
import { defineStore } from 'pinia'

export const useStore = defineStore('store', {
  state: () => ({
    someState: 'hello pinia',
  }),
  persist: true,
})

Configuration

You can configure how a store is persisted by specifying options to the persist property:

export const useStore = defineStore('store', () => {
  const someState = ref('hello pinia')
  return { someState }
}, {
  persist: {
    storage: sessionStorage,
    pick: ['someState'],
  },
})

All the available configuration options are explained here.

Usage with Nuxt

Nuxt support comes out of the box thanks to the included module. You just need to install the package and add the module to your nuxt.config.ts as follows:

export default defineNuxtConfig({
  modules: [
    '@pinia/nuxt', // required
    'pinia-plugin-persistedstate/nuxt',
  ],
})

More information on storages and configuration in Nuxt here.

Limitations

There are several limitations that should be considered, more on those here.

Contributing

See the contribution guide.

License

MIT © 2021-present Sacha Bouillez

nuxt
nuxt-module
pinia
pinia-plugin

prazdevs/pinia-plugin-persistedstate

💾 Configurable persistence and rehydration of Pinia stores

TypeScript

2,513

468 commits

updated Aug 31, 2025

See the code

README

[!IMPORTANT] This project has a new home at codeberg.org/praz/pinia-plugin-persistedstate.
Everything (issues included) has been migrated and development/maintenance will continue over there.

pinia-plugin-persistedstate

npm version bundle size license

Configurable persistence and rehydration of Pinia stores.

Read the full documentation

Features

  • Persist Pinia stores with a friendly API inspired by vuex-persistedstate.
  • Highly customizable (storage, serializer, paths picking/omitting).
  • Out of the box SSR-friendly support for Nuxt.
  • Very smol (<2kB minzipped).

Quickstart

  1. Install with your favorite package manager:

    • pnpm : pnpm add pinia-plugin-persistedstate
    • npm : npm i pinia-plugin-persistedstate
    • yarn : yarn add pinia-plugin-persistedstate
  2. Add the plugin to pinia:

import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
  1. Add the persist option to the store you want to be persisted:
import { defineStore } from 'pinia'

export const useStore = defineStore('store', {
  state: () => ({
    someState: 'hello pinia',
  }),
  persist: true,
})

Configuration

You can configure how a store is persisted by specifying options to the persist property:

export const useStore = defineStore('store', () => {
  const someState = ref('hello pinia')
  return { someState }
}, {
  persist: {
    storage: sessionStorage,
    pick: ['someState'],
  },
})

All the available configuration options are explained here.

Usage with Nuxt

Nuxt support comes out of the box thanks to the included module. You just need to install the package and add the module to your nuxt.config.ts as follows:

export default defineNuxtConfig({
  modules: [
    '@pinia/nuxt', // required
    'pinia-plugin-persistedstate/nuxt',
  ],
})

More information on storages and configuration in Nuxt here.

Limitations

There are several limitations that should be considered, more on those here.

Contributing

See the contribution guide.

License

MIT © 2021-present Sacha Bouillez

nuxt
nuxt-module
pinia
pinia-plugin

Project health

Latest release

4.7.1 · Nov 1, 2025

Releases this year

3

Significant stargazers

Nico Devs

101 followers · starred Feb 2024

Simon Lecoq

1,775 followers · starred May 2022

Valentin Fritz

45 followers · starred Jul 2025

swithek

45 followers · starred Nov 2024