Registry / storage / js-storage

js-storage

JSON →
library1.1.0jsnpmunverified

A JavaScript plugin (v1.1.0) that simplifies access to HTML5 storages (localStorage, sessionStorage) and cookies, with automatic JSON serialization, namespace support, and cookie fallback for old browsers. It provides a unified API for get/set/keys/isEmpty/hasKey operations with dot-path access to nested objects and bulk operations. Unlike raw localStorage, it automatically encodes objects via JSON, supports namespaces to avoid key collisions, and optionally integrates js-cookie for cookie storage. Stable but low maintenance; last updated several years ago.

npm install js-storage
INSTALL
IMPORT
SIG · JS-STORAGE
J
js-storage
storagejavascriptv1.1.0
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.

Storages
import { Storages } from 'js-storage'
const Storages = require('js-storage')
Package provides named export 'Storages'. ESM import is correct; CommonJS require works but may be deprecated.
localStorage
Storages.localStorage
Storages.localStorage.get()
Access the localStorage storage handler via Storages object, then call methods.
initNamespaceStorage
Storages.initNamespaceStorage('ns_name')
initNamespaceStorage('ns_name')
Must be called on Storages object, not as standalone.

Basic usage: import Storages, set/get values with automatic JSON encoding, dot-path access, namespace storage, and utility methods.

import { Storages } from 'js-storage'; // Access localStorage const storage = Storages.localStorage; // Set a value storage.set('user', { name: 'John', age: 30 }); // Get a value (automatic JSON deserialization) const user = storage.get('user'); console.log(user.name); // 'John' // Dot-path access storage.set('config.theme', 'dark'); console.log(storage.get('config.theme')); // 'dark' // Namespace storage const ns = Storages.initNamespaceStorage('myApp'); ns.localStorage.set('key', 'value'); // Keys console.log(storage.keys()); // ['user', 'config'] // Check existence console.log(storage.isSet('user')); // true // Check empty console.log(storage.isEmpty('nonexistent')); // true
Debug
Known issues
deprecatedPackage is not actively maintained; last update was several years ago.
fix
Consider using modern alternatives like localForage or simple localStorage API.
affects: >=1.0.0
gotchaCookie storage requires js-cookie dependency; without it, Storages.cookieStorage is undefined.
fix
Install js-cookie: npm install js-cookie
affects: >=1.0.0
gotchaget() returns null for missing keys, not undefined.
fix
Check with isSet() or isEmpty() to differentiate missing vs empty.
affects: >=1.0.0
breakingVersion 1.0.0 changed from global Storages to module export; breaking for script-tag users.
fix
Use import/require instead of relying on window.Storages.
affects: 1.0.0
Errors
Common errors & fixes
Uncaught ReferenceError: Storages is not defined
Trying to use Storages without proper import
fix
Add import { Storages } from 'js-storage' at top of file.
Storages.cookieStorage is undefined
js-cookie is not installed or not loaded
fix
Install js-cookie: npm install js-cookie and import before js-storage.
TypeError: storage.set is not a function
Using incorrect method name or accessing non-existent storage
fix
Ensure storage is one of Storages.localStorage, Storages.sessionStorage, or Storages.cookieStorage.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
js-cookieoptionalRequired for cookie storage functionality
Agent activity
21 hits · last 30 days
node
20
OpenAI (training)
1
Resources
js-storage — npm install js-storage · libregistry