vue-ls logo


Vue plugin for work with local storage, session storage and memory storage from Vue context


jsFiddle Example

Vue 1.x

Vue 2.x



Recommended:, which will reflect the latest version as soon as it is published to npm. You can also browse the source of the npm package at

Also available on jsDelivr or cdnjs, but these two services take some time to sync so the latest release may not be available yet.


npm install vue-ls --save


yarn add vue-ls


bower install vue-ls --save

Development Setup

# install dependencies
npm install

# build dist files
npm run build


Vue storage API.

import Storage from 'vue-ls';

options = {
  namespace: 'vuejs__', // key prefix
  name: 'ls', // name variable Vue.[ls] or this.[$ls],
  storage: 'local', // storage name session, local, memory

Vue.use(Storage, options);


new Vue({
    el: '#app',
    mounted: function() {'foo', 'boo');
        //Set expire for item'foo', 'boo', 60 * 60 * 1000); //expiry 1 hour'foo');'boo', 10); //if not set boo returned default 10
        let callback = (val, oldVal, uri) => {
          console.log('localStorage change', val);
       'foo', callback) //watch change foo key and triggered callback'foo', callback) //unwatch



API, def)

Returns value under name in storage. Internally parses the value from JSON before returning it., value, expire)

Persists value under name in storage. Internally converts the value to JSON.

Removes name from storage. Returns true if the property was successfully deleted, and false otherwise.

Clears storage., callback)

Listen for changes persisted against name on other tabs. Triggers callback when a change occurs, passing the following arguments., callback)

Removes a listener previously attached with, callback).


Testing Supported By


Some browsers don’t support the storage event, and most of the browsers that do support it will only call it when the storage is changed by a different window. So, open your page up in two windows. Click the links in one window and you will probably see the event in the other.

The assumption is that your page will already know all interactions with localStorage in its own window and only needs notification when a different window changes things. This, of course, is a foolish assumption. But.

Other my Vue JS plugins

Project Status Description
vue-gallery npm VueJS responsive and customizable image and video gallery
vue-popper npm VueJS popover component based on popper.js


FOSSA Status

MIT © Igor Ognichenko