vue-localstore

Vue plugin for localForage.
4,240
Install
npm install vue-localstore
Latest Version:0.1.0
License:Apache-2.0
Last Updated:May 13, 2018
Links: GitHub  ·  npm
Maintainer: alex-c

vue-localstore

Vue plugin for localForage. Binds localForage to Vue instances as $localstore.

Installation

Install vue-localstore with npm (or alternatively yarn):

npm --save install vue-localstore

Then add it to Vue in your main.js:

const VueLocalStore = require('vue-localstore');
Vue.use(VueLocalStore);

Usage

Since localForage is exposed directly to this.$localstore, you can use both the callback-based and Promsie-based API.

this.$localstore.setItem('key', 'value').then(function () {
    return this.$localstore.getItem('key');
}).then(function (value) {
    // we got our value
}).catch(function (err) {
    // we got an error
});

Configuration

When adding vue-localstore to Vue, you can pass a configuration object. This causes $localstore to point to a configured localForage instance (see localForage documentation sections Configuration and Multiple instances):

const VueLocalStore = require('vue-localstore');

Vue.use(VueLocalStore, {
    driver      : localforage.WEBSQL, // Force WebSQL; same as using setDriver()
    name        : 'myApp',
    version     : 1.0,
    size        : 4980736, // Size of database, in bytes. WebSQL-only for now.
    storeName   : 'keyvaluepairs', // Should be alphanumeric, with underscores.
    description : 'some description'
});

Related Packages

pinia-plugin-state-persistence

Pinia plugin for universal state persistence across synchronous and asynchronous...

39,095 103
pinia-plugin-persistedstate

Configurable persistence and rehydration of Pinia stores.

24,673,653
@igortrindade/pinia-plugin-persistedstate

Configurable persistence and rehydration of Pinia stores.

5,551 2,512
vue-router-query-sync

Reactive, typed view of Vue Router query params with codecs and defaults

2,354 1

Version History

Version Released License
0.1.0 Apache-2.0