pinia-plugin-state-persistence

Pinia plugin for universal state persistence across synchronous and asynchronous storage systems, supporting advanced features like path inclusion/exclusion and custom serialization.
39,095 103
Install
npm install pinia-plugin-state-persistence
Latest Version:1.12.20
Vue:3
License:MIT
Last Updated:Oct 5, 2026
Links: GitHub  ·  npm
Maintainer: stephenjason89

Overview

This project is a Pinia plugin designed to provide state persistence capabilities for Vue applications. It enables developers to persist store states across sessions using various storage options, including synchronous and asynchronous storage mechanisms. The plugin is configurable and supports advanced features like filtering mutations and custom serialization/deserialization.

Features

  • Universal Storage Support: Works with both synchronous and asynchronous storage mechanisms, including localStorage, cookies, and libraries like localForage or even custom remote APIs.
  • Customizable Persistence: Configure key names, mutation filters, and serialization/deserialization methods.
  • Debugging Support: Includes a built-in logger to track plugin operations.
  • State Overwriting: Optionally overwrite the store state during initialization.
  • SSR Compatibility: Fully supports server-side rendering environments, addressing edge cases with seamless state handling.

Why Choose This Plugin?

  • Zero Dependencies: This plugin is lightweight and has no external dependencies (other than Pinia itself), ensuring minimal impact on your application's bundle size.
  • Compact Size: The bundle's minified gzip size is only 1 kB, making it highly efficient for production use.
  • Async Storage Support: Unlike other plugins, this plugin natively supports asynchronous storage mechanisms such as localForage, making it ideal for modern applications.
  • Queueing Mechanism: Introduces a queueing mechanism to eliminate race condition issues during state persistence.
  • Enhanced Flexibility: Offers advanced configuration options, including custom merge strategies, state filters, and serialization methods, ensuring it adapts to diverse use cases.
  • Reliable State Management: Resolves common issues with state persistence in both client-side and SSR setups, providing a smoother developer experience.
  • Developer-Centric Approach: Built with contributions and feedback in mind, ensuring issues are addressed promptly and features align with real-world needs.

Quick Links

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For questions or support, please open an issue or start a discussion on GitHub.

Related Packages

pinia-plugin-persistedstate

Configurable persistence and rehydration of Pinia stores.

24,673,653
@igortrindade/pinia-plugin-persistedstate

Configurable persistence and rehydration of Pinia stores.

5,551 2,512
pinia-plugin-unistorage

uniapp 下 pinia 的本地数据缓存插件

12,081 23
pinia-persistence-plugin

Pinia persistence plugin

7,392 2
@pinia/nuxt

Nuxt Module for pinia

34,268,649 14,743

Version History

Version Released License
1.12.20 MIT
1.12.19 MIT
1.12.18 MIT
1.12.17 MIT
1.12.16 MIT