Registry / storage / storejs

storejs

JSON →
library2.1.1jsnpmunverified

store.js is a lightweight, cross-browser wrapper for localStorage with a simple, unified API. Version 2.1.1 is stable, actively maintained, and ships TypeScript definitions. It provides methods like set, get, remove, clear, forEach, and a Node.js shim. Unlike raw localStorage, store.js automatically serializes/deserializes values, handles errors, and has no dependencies. It supports all major browsers and Node.js v6+.

npm install storejs
INSTALL
IMPORT
SIG · STOREJS
S
storejs
storagejavascriptv2.1.1
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.

store
import store from 'storejs'
const store = require('storejs')
Default import in ESM; also works with CommonJS require but TypeScript prefers ESM.
set
import { set } from 'storejs'
import { set } from 'store'
Named import available since v2.0.0.
get
import { get } from 'storejs'
const get = require('storejs').get
Named exports are ES-module only; CommonJS users use store.get().
remove
import { remove } from 'storejs'
import remove from 'storejs'
remove is a named export, not the default.

Basic CRUD operations with store.js: set, get, remove, clear, forEach, keys, has, and size.

import store from 'storejs'; // Store data (auto-serializes) store.set('username', 'marcus'); store.set('settings', { theme: 'dark', notifications: true }); // Retrieve data const user = store.get('username'); // 'marcus' const settings = store.get('settings'); // { theme: 'dark', notifications: true } // Remove a key store.remove('username'); // Clear all store.clear(); // Iterate store.set('a', 1); store.set('b', 2); store.forEach((key, value) => console.log(key, value)); // Get all keys const keys = store.keys(); // ['a', 'b'] // Check if key exists if (store.has('a')) console.log('exists'); // Get storage size const size = store.size(); // 2 // Handle errors gracefully store.set('key', 'value');
Debug
Known issues
gotchastore.set() may throw if localStorage is full or disabled in Safari private mode.
fix
Wrap in try/catch or use store.disabled to check availability.
affects: >=2.0.0
gotchaValues are serialized via JSON.stringify. Custom objects with methods or non-JSON-safe values will be corrupted.
fix
Use only JSON-serializable values or implement custom serialization.
affects: all
gotchastore.keys() returns an array of keys; it does not return a storage event iterator.
fix
Use store.forEach() to iterate over key-value pairs.
affects: all
deprecatedstore.engine is deprecated and will be removed in v3. Use store.area() to switch engines.
fix
Replace store.engine with store.area('local') or store.area('session').
affects: 2.x
Errors
Common errors & fixes
Uncaught ReferenceError: require is not defined
Using CommonJS require in a browser ESM context.
fix
Use import store from 'storejs' or add a bundler.
TypeError: store.set is not a function
Importing from wrong package or default export not used.
fix
Ensure import store from 'storejs'; (not from 'store').
QuotaExceededError
localStorage full exceeds 5-10 MB limit.
fix
Catch error and notify user to clear storage.
store('key') is not a function
Trying to call store as a function (old v1 API was store(key, value)).
fix
Use store.set('key', 'value') instead.
Upgrade
Version history
2.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
18
Amazon
1
Resources
storejs — npm install storejs · libregistry