Registry / storage / cross-storage

cross-storage

JSON →
library1.0.0jsnpmunverified

Cross domain local storage library enabling multiple browser windows/tabs across different domains to share a single localStorage. Provides an API using ES6 promises. Version 1.0.0 is the latest stable release (in maintenance mode). Differentiators: alternative to cookies with larger storage (up to 2.49M chars), avoids request header overhead. Uses hub/client architecture with iframe postMessage communication, enforced origin permissions via RegExp patterns.

npm install cross-storage
INSTALL
IMPORT
SIG · CROSS-STORAGE
C
cross-storage
storagejavascriptv1.0.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.

CrossStorageClient
import { CrossStorageClient } from 'cross-storage'
import CrossStorageClient from 'cross-storage'
Named export, not default. Also available via require.
CrossStorageHub
import { CrossStorageHub } from 'cross-storage'
const CrossStorageHub = require('cross-storage').CrossStorageHub
Named export; CommonJS require works but ESM preferred.
CrossStorageClient
const { CrossStorageClient } = require('cross-storage')
const CrossStorageClient = require('cross-storage')
Requires destructuring, not default export.

Initialize hub with permissions, then create a client, connect, set, and get a value.

// Hub: serve this script on https://store.example.com/hub.html CrossStorageHub.init([ {origin: /\.example\.com$/, allow: ['get']}, {origin: /:\/\/(www\.)?example\.com$/, allow: ['get', 'set', 'del']} ]); // Client var storage = new CrossStorageClient('https://store.example.com/hub.html'); storage.onConnect().then(function() { return storage.set('key', 'value'); }).then(function() { return storage.get('key'); }).then(function(val) { console.log(val); }).catch(function(err) { console.error(err); });
Debug
Known issues
gotchaCORS and iframe same-origin policy: Hub and client must be served over HTTPS if parent page is HTTPS, else messages blocked.
fix
Ensure hub URL uses same protocol (HTTP vs HTTPS) as client page.
affects: >=0.0.0
gotchaPermissions RegExp must match origin exactly; trailing $ required to avoid matching malicious subdomains.
fix
Use patterns like /\.example\.com$/ to prevent origin spoofing.
affects: >=0.0.0
deprecatedlibrary is no longer actively maintained; no bug fixes or security patches since 2016.
fix
Consider alternatives like postMessage-based libraries or iframe storage solutions.
affects: >=1.0.0
Errors
Common errors & fixes
CrossStorageClient is not a constructor
Importing default instead of named export.
fix
Use `import { CrossStorageClient } from 'cross-storage'`.
Uncaught DOMException: Blocked a frame with origin "http://client.example.com" from accessing a cross-origin frame.
Hub and client different origins, or hub not served correctly.
fix
Host hub.html on the same origin as specified in permissions; ensure CORS headers if necessary.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
22
Amazon
1
Resources
cross-storage — npm install cross-storage · libregistry