Skip to content

Why this plugin ?

This plugin was born in the early days of Pinia, before it officially replaced VueX. It initially aimed to reproduce vuex-persistedstate for Pinia.

Do I need a plugin to persist my stores ?

Short answer: “no”. There are a lot of solutions to persist store data in storages such as localStorage that don’t even involve injecting a plugin into Pinia. Here is an example using VueUse’s useLocalStorage :

ts
import { useLocalStorage } from '@vueuse/core'
import { defineStore } from 'pinia'

defineStore('store', () => {
  const someState = useLocalStorage('stored-state', 'initialValue')

  return { someState }
})

Why would I need this plugin ?

The pinia-plugin-persistedstate plugin aims to provide persistence to Pinia stores for everyone and in every project with a consistent API. Whether you are fine with the defaults to save a complete store, or you need fine-grained configuration with multiple storages and a custom serializer, the plugin got you covered, all within the same persist option on the stores you want to persist.

This plugin is actively maintained to bring you the best developer experience possible with persisting your stores. If you have a question, encounter a bug, or want to propose new features, you are very much welcome on the GitHub repository to contribute.

Released under the MIT License.