1.1.0 • Published 1 year ago

persistia v1.1.0

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
1 year ago

persistia

Persist Pinia state data in localStorage

Installation

Install with your favourite package manager:

# yarn
yarn add persistia

# pnpm
pnpm add persistia

# npm
npm install persistia

Import and install:

// main.js
import { createPinia } from 'pinia'
import { persistia } from 'persistia'

const pinia = createPinia()
pinia.use(persistia)

Enable the plugin per store:

import { defineStore } from 'pinia'

export const useStore = defineStore('...', {
  persist: true,

  state: () => ({ ... }),

  actions: { ... },

  getters: { ... }
})

Alternatively, you can specify which keys in state to persist:

import { defineStore } from 'pinia'

export const useStore = defineStore('...', {
  persist: ['name', 'age'],

  state: () => ({
    name: 'Jane Doe',
    age: 42,
    email: 'jane@example.com',
    address: '123 Fake St.'
  }),

  actions: { ... },

  getters: { ... }
})

License

MIT

1.1.0

1 year ago

1.0.0

2 years ago

1.0.0-fix.0

2 years ago

1.0.0-fix.1

2 years ago

1.0.0-fix.2

2 years ago

0.1.4

2 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago