Giter VIP home page Giter VIP logo

pinia-persistedstate-plugin's Introduction

pinia-persistedstate-plugin

English | δΈ­ζ–‡

A pinia plugin like vuex-persistedstate.

Install

npm install pinia-persistedstate-plugin

or

yarn add pinia-persistedstate-plugin

or

pnpm add pinia-persistedstate-plugin

The UMD build is also available on unpkg:

<script src="https://unpkg.com/pinia-persistedstate-plugin/dist/pinia-persistedstate-plugin.umd.js"></script>

You can find the library on window.PiniaPersistedstatePlugin.

Usage

In main.ts:

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { createPersistedState } from 'pinia-persistedstate-plugin'
import App from './App.vue'

const app = createApp(App)
const store = createPinia()

store.use(createPersistedState())

app.use(store).mount('#app')

use js-cookie

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { createPersistedState } from 'pinia-persistedstate-plugin'
import App from './App.vue'
import Cookies from 'js-cookie'

const app = createApp(App)
const store = createPinia()

store.use(
  createPersistedState({
    storage: Cookies
  })
)

app.use(store).mount('#app')

Options

export interface Options {
  /**
   * storage, default is `window.localStorage`
   *
   * support `js-cookie` `window.localStorage` `window.sessionStorage`
   */
  storage?: Storage | Cookies
  /**
   * storage key prefix, default is `pinia`
   */
  key: string
  /**
   * is open logger, default is `false`
   */
  logger: boolean
}

License

MIT License.

pinia-persistedstate-plugin's People

Contributors

l-x-f avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.