Registry / storage / vue2-storage

vue2-storage

JSON →
library6.1.3jsnpmunverified

Browser storage plugin for Vue.js 2.x applications, providing a reactive wrapper around localStorage, sessionStorage, and memoryStorage. Current version 6.1.3 is stable with TypeScript support. Released under MIT license, it offers a simple API for setting, getting, removing, and clearing stored values with automatic JSON serialization/deserialization. It integrates seamlessly as a Vue plugin, exposing `$storage` on Vue instances, or can be used standalone in vanilla JavaScript. Alternative to vue-ls and vue-localstorage, with focus on minimalism and Vue 2 reactivity.

npm install vue2-storage
INSTALL
IMPORT
SIG · VUE2-STORAGE
V
vue2-storage
storagejavascriptv6.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Vue2StoragePlugin
import { Vue2StoragePlugin } from 'vue2-storage'
Named export; use as a Vue plugin.
Vue2Storage
import { Vue2Storage } from 'vue2-storage'
const Vue2Storage = require('vue2-storage').Vue2Storage
Class for standalone usage without Vue.
Vue2StorageOptions
import type { Vue2StorageOptions } from 'vue2-storage'
TypeScript interface for options object.

Vue 2 plugin installation with namespace and storage type, setting and getting a JSON value.

import Vue from 'vue'; import { Vue2StoragePlugin } from 'vue2-storage'; Vue.use(Vue2StoragePlugin, { namespace: 'myapp_', storage: 'local', }); new Vue({ created() { this.$storage.set('key', { foo: 'bar' }); console.log(this.$storage.get('key')); // { foo: 'bar' } this.$storage.remove('key'); this.$storage.clear(); } }).$mount('#app');
Debug
Known issues
breakingIn version 6.0.0, the import path changed from 'vue2-storage/dist/vue2-storage' to 'vue2-storage'. Also, Vue2StoragePlugin replaces the previous default export.
fix
Update to import { Vue2StoragePlugin } from 'vue2-storage'.
affects: <6.0.0
gotchaUsing the plugin in a non-Vue environment (e.g., plain Node.js) will fail because Vue is a peer dependency and the plugin assumes a Vue instance.
fix
Use the standalone Vue2Storage class directly: import { Vue2Storage } from 'vue2-storage'.
affects: >=1.0.0
deprecatedThe 'memory' storage type is deprecated in favor of 'memoryStorage' for consistency with other storage names.
fix
Use { storage: 'memoryStorage' } instead of 'memory'.
affects: >=4.0.0
Errors
Common errors & fixes
Cannot read property 'prototype' of undefined
Importing the plugin without Vue installed or importing in a non-Vue context.
fix
Ensure Vue is installed and imported before using the plugin. For standalone usage, use Vue2Storage class instead.
TypeError: this.$storage.set is not a function
The plugin was not installed via Vue.use() or used outside of a Vue component context.
fix
Call Vue.use(Vue2StoragePlugin, options) before creating the root Vue instance.
Upgrade
Version history
6.1.3latest on npm
Audit
Dependencies
vuerequiredPeer dependency required for Vue plugin integration
Agent activity
33 hits · last 30 days
node
28
OpenAI (training)
1
Resources
vue2-storage — npm install vue2-storage · libregistry