@jswork/pinia-plugin-persist
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

pinia-plugin-persist

Persist pinia state data storages.

version license size download

installation

npm install @jswork/pinia-plugin-persist

usage

import PiniaPluginPersist from '@jswork/pinia-plugin-persist';

// ======== main.js  ======
export function createApp() {
  const app = createSSRApp(App);
  const pinia = createPinia();

  // Attach storage
  app.$storage = nx.$storage;
  pinia.use(PiniaPluginPersist);
  //...
}

// ======== stores/auth.js ======
import { defineStore } from "pinia";

export default defineStore("auth", {
  state: () => ({ profile: null, user: null, other: null }),
  persist: {
    keys: ["profile", "user"]
  },
});

license

Code released under the MIT license.

Package Sidebar

Install

npm i @jswork/pinia-plugin-persist

Homepage

js.work

Weekly Downloads

8

Version

1.0.6

License

MIT

Unpacked Size

8.79 kB

Total Files

6

Last publish

Collaborators

  • afeiship