Skip to content

lgd8981289/vuex-persistedstate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vuex-persistedstate

Persist and rehydrate your Vuex state between page reloads.

robinvdvleuten/vuex-persistedstate Maintenance has stopped, but a lot of developers are still using vuex-persistedstate , so we try to replace it。

will try to keep the same API to achieve risk-free replacement.


Install

npm install --save vuex-plugin-persistedstate

The UMD build is also available on unpkg:

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

Usage

import { createStore } from "vuex";
import createPersistedState from "vuex-plugin-persistedstate";

const store = createStore({
  // ...
  plugins: [createPersistedState()],
});

Compatible with vuex 3 && vuex 4

Examples

Check out a basic example on CodeSandbox.

Edit vuex-persistedstate

Options

export interface Options<State> {
  /**
   * localStorage saved key
   */
  key: string
  /**
   * cached module name
   * Do not pass means cache all
   * pass only the specified cache
   */
  paths: string[]
  /**
   * storage
   */
  storage: Storage
  /**
   * Whether to prefetch data
   */
  fetchBeforeUse: boolean
  /**
   * Default method of prefetching data
   */
  fetchBeforeUseFn: (key: string, storage: Storage) => any
}

License

The MIT License (MIT). Please see License File for more information.

About

Persist and rehydrate your Vuex state between page reloads.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published