Registry / storage / superstore-sync

superstore-sync

JSON →
library2.1.1jsnpmunverified

A synchronous wrapper around localStorage and sessionStorage that automatically handles JSON serialization/deserialization and provides resilience to iOS private browsing mode quirk. Current stable version is 2.1.1. Maintained with minimal releases; key differentiators include built-in JSON handling and protection against iOS Storage bugs.

npm install superstore-sync
INSTALL
IMPORT
SIG · SUPERSTORE-SYNC
S
superstore-sync
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.

local
✓ import { local } from 'superstore-sync'
✗ const local = require('superstore-sync').local
ESM-style import since v2; avoid CommonJS destructuring if using ESM.
session
✓ import { session } from 'superstore-sync'
✗ var store = require('superstore-sync'); store.session
Both local and session can be imported as named exports.
isPersisting
✓ import { isPersisting } from 'superstore-sync'
✗ const store = require('superstore-sync'); store.isPersisting
isPersisting is also a named export; v2 supports named imports.
default
✓ import store from 'superstore-sync'
✗ const store = require('superstore-sync').default
Default export is the module itself; no .default needed with ESM.

Shows how to use local, session, isPersisting, clear, unset with automatic JSON handling.

import { local, session, isPersisting } from 'superstore-sync'; // Set and get from local storage local.set('name', { first: 'Alice', last: 'Smith' }); const name = local.get('name'); console.log(name.first); // 'Alice' // Set and get from session storage session.set('sessionId', 12345); const id = session.get('sessionId'); console.log(id); // 12345 // Clear all keys starting with 'foo' local.clear('foo'); // Check persistence status console.log(isPersisting()); // true unless storage is full/unavailable // Remove a specific key local.unset('name'); // Unset from session session.unset('sessionId');
Debug
Known issues
gotchaThe get() method can return null if the key does not exist. Code assuming object return may break.
fix
Always check for null: const val = local.get('key'); if (val !== null) { ... }
affects: >=0.0.0
gotchaUsing require('superstore-sync') returns a module object; local/session are properties, not top-level exports in CJS. Named imports are available via ESM.
fix
For CJS: const store = require('superstore-sync'); store.local.set(...). For ESM: import { local } from 'superstore-sync'.
affects: >=1.0.0
deprecatedThe #unset method is deprecated in favor of #removeKey (if available) or using delete operator directly on Storage. However, superstore-sync does not support removeKey; unset still works.
fix
Use local.set(key, null) or local.unset(key) as documented.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: local.get is not a function
Using destructuring with CommonJS require: const { local } = require('superstore-sync')
fix
Use const store = require('superstore-sync'); store.local.get(...)
Cannot read property 'set' of undefined
Importing default as 'store' in CommonJS but trying to use store.set(...) directly (store is the module, not local/session).
fix
Use store.local.set(...) or import named exports with ESM.
localStorage is not defined (ReferenceError)
Running in Node.js environment where localStorage is not available.
fix
Use a polyfill or only use in browser context. superstore-sync relies on window.localStorage.
Upgrade
Version history
2.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
36 hits · last 30 days
node
34
OpenAI (training)
1
Resources
superstore-sync — npm install superstore-sync · libregistry