Skip to content

litingyes/pinia-plugin-unstorage

Repository files navigation

pinia-plugin-unstorage

The best persistence plugin for pinia.

Tip

The persistence logic of this plugin is implemented based on unstorage, which provide unified key-value storage API. Based on this, you can even persist the data to the database

Install

pnpm add pinia-plugin-unstorage

Usage

Vue app

import { createPinia } from 'pinia'
import { createPiniaUnstorage } from 'pinia-plugin-unstorage'

const pinia = createPinia()
pinia.use(createPiniaUnstorage({
  // UnstorageOptions
}))

Nuxt app

export default defineNuxtConfig({
  modules: ['@pinia/nuxt', 'pinia-plugin-unstorage/nuxt'],
  piniaUnstorage: {
    // UnstorageOptions
  },
})

Options

Plugin options

interface UnstorageOptions {
  namespace: string // prefix str to as storage key
  driver: Driver // the storage instance in unstorage
}

Store options

export const useStore = defineStore('store', () => {
  // ...
}, {
  unstorage: {
    pick: [], // string[], state keys picked to storage
    omit: [] // string[], state keys omitted fot storage
  }
})

About

The best persistence plugin for pinia.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy