Pinia Persistence and Devtools
pinia-plugin-persistedstate, persisting only specific fields, Pinia devtools time-travel.
Persisting Store State
By default, Pinia state is lost on page reload. To keep it, use the pinia-plugin-persistedstate plugin, which syncs state to localStorage or sessionStorage.
Installing the Plugin
Register the plugin on the Pinia instance once. Every store can then opt in.
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)All lessons in this course
- Pinia vs Vuex: Why the Switch
- defineStore: State, Getters, Actions
- Composing Stores and Cross-Store Access
- Pinia Persistence and Devtools