pinia-persists

a pinia plugin for state persist.
792 16
Install
npm install pinia-persists
Latest Version:1.2.0
Vue:3
License:MIT
Last Updated:Apr 27, 2022
Links: GitHub  ·  npm
Maintainer: ouduidui

Pinia Persists

A pinia plugin for state persist.

NPM version

English | 简体中文

Usage

Install

npm i pinia-persists

Use

import { persist } from 'pinia-persists'
import { createPinia } from 'pinia'

const pinia = createPinia()

// pinia use plugin
pinia.use(persist({ /* options */ }))

app.use(pinia)

Options

prefix

  • type: String
  • optional, default "pinia"
  • it is the prefix of the key to store the persisted state under, such as the store id is "test", that store key is "pinia_test" by default.

storage

  • type: Object

    interface Storage {
        readonly length?: number;
        clear?: () => void;
        getItem: (key: string) => string | null;
        key?: (index: number) => string | null;
        removeItem?: (key: string) => void;
        setItem: (key: string, value: string) => void;
        [name: string]: any;
    }
    
  • optional, default window.localStorage

  • it is the storage for state persist, you can choose localStorage, sessionStorage or your custom storage.

overwrite

  • type: Boolean
  • optional, default false
  • when app first loader or refresh, whether to overwrite the existing state with the output from state directly, instead of merging the two objects with deep merge.

License

MIT License © 2022 Dewey Ou

Related Packages

pinia-plugin-store

pinia plugin store

15,186 10
pinia-plugin-unstorage

The best persistence plugin for pinia.

7,927
pinia-simple-persist

Simple pinia persistence without using $patch

1,346 0
pinia-generic

pinia-generic provides conventions to create generic stores, and it also support...

675 7
pinia-use-persist

Easy to use persist plugin with configurable encryption, Currently in developmen...

2,164

Version History

Version Released Vue License
1.2.0 ^3.2.33 MIT
1.1.0 ^3.2.33 MIT
1.0.1 ^3.2.31 MIT
0.1.0 ^3.2.31 MIT
0.0.2 ^3.2.31 MIT
Pre-releases (2)
Version Released Vue License
0.0.3-beta.2 ^3.2.31 MIT
0.0.3-beta.1 ^3.2.31 MIT