# pinia-plugin-persistedstate

> Configurable persistence and rehydration of Pinia stores.

Latest version **4.7.1** (published 2025-11-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install pinia-plugin-persistedstate
pnpm add pinia-plugin-persistedstate
yarn add pinia-plugin-persistedstate
bun add pinia-plugin-persistedstate
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.7.1 |
| Published | 2025-11-01 |
| First published | 2021-10-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 49.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | praz |
| Maintainers | prazdevs |
| Keywords | vue, store, pinia, persistence, pinia-plugin, nuxt, nuxt-module |

## Links

- npm: https://www.npmjs.com/package/pinia-plugin-persistedstate
- Repository: https://codeberg.org/praz/pinia-plugin-persistedstate
- Homepage: https://praz.codeberg.page/pinia-plugin-persistedstate
- Issues: https://codeberg.org/praz/pinia-plugin-persistedstate/issues
- npm.io page: https://npm.io/package/pinia-plugin-persistedstate

## Dependencies (1)

- [defu](https://npm.io/package/defu.md) ^6.1.4

## Recent versions

- 4.7.1 (latest) — 2025-11-01
- 4.0.0-alpha.11 (alpha) — 2024-09-01
- 2.1.0-beta.0 (beta) — 2022-08-02
- 4.7.0 — 2025-11-01
- 4.6.0 — 2025-11-01
- 4.5.0 — 2025-08-11
- 4.4.1 — 2025-06-30
- 4.4.0 — 2025-06-28
- 4.3.0 — 2025-05-10
- 4.2.0 — 2024-12-16
- 4.1.3 — 2024-11-08
- 4.1.2 — 2024-10-25
- 4.1.1 — 2024-10-04
- 4.1.0 — 2024-10-04
- 4.0.2 — 2024-09-18
- … 49 more at https://npm.io/package/pinia-plugin-persistedstate/versions

## README

# pinia-plugin-persistedstate

[![npm version][version-src]][version-href]
[![bundle size][bundle-src]][bundle-href]
[![license][license-src]][license-href]

> Configurable persistence and rehydration of Pinia stores.

[**_Read the full documentation_**](https://praz.codeberg.page/pinia-plugin-persistedstate)

## Features

- Persist Pinia stores with a friendly API inspired by [`vuex-persistedstate`](https://github.com/robinvdvleuten/vuex-persistedstate).
- Highly customizable (storage, serializer, paths picking/omitting).
- Out of the box SSR-friendly support for [`Nuxt`](#usage-with-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:

```ts
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
```

3. Add the `persist` option to the store you want to be persisted:

```ts
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:

```ts
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](https://praz.codeberg.page/pinia-plugin-persistedstate/guide/config).

## 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:

```ts
export default defineNuxtConfig({
  modules: [
    '@pinia/nuxt', // required
    'pinia-plugin-persistedstate/nuxt',
  ],
})
```

More information on storages and configuration in Nuxt [here](https://praz.codeberg.page/pinia-plugin-persistedstate/frameworks/nuxt).

## Limitations

There are several limitations that should be considered, more on those [here](https://praz.codeberg.page/pinia-plugin-persistedstate/guide/limitations).

## Contributing

See the [contribution guide](https://codeberg.org/praz/pinia-plugin-persistedstate/src/branch/main/CONTRIBUTING.md).

## License

[MIT](https://codeberg.org/praz/pinia-plugin-persistedstate/src/branch/main/LICENSE) © 2021-present [praz](https://codeberg.org/praz)

[version-src]: https://img.shields.io/npm/v/pinia-plugin-persistedstate?style=flat-square&labelColor=313244&color=cba6f7
[version-href]: https://npmjs.com/package/pinia-plugin-persistedstate
[bundle-src]: https://img.shields.io/bundlejs/size/pinia-plugin-persistedstate?style=flat-square&labelColor=313244&color=cba6f7
[bundle-href]: https://bundlejs.com/?q=pinia-plugin-persistedstate
[license-src]: https://img.shields.io/npm/l/pinia-plugin-persistedstate?style=flat-square&labelColor=313244&color=cba6f7
[license-href]: https://codeberg.org/praz/pinia-plugin-persistedstate/src/branch/main/LICENSE

---
_Source: https://npm.io/package/pinia-plugin-persistedstate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
