{"id":47342,"library":"cross-domain-storage","title":"cross-domain-storage","description":"cross-domain-storage v2.0.7 enables browser-localStorage sharing across subdomains and parent/child windows via postMessage. Low-maintenance, no new releases since 2016. Ideal for simple cross-origin persistence without server-side setup. Minimal API, uses iframe or window messaging. Lightweight, no external dependencies.","status":"maintenance","version":"2.0.7","language":"javascript","source_language":"en","source_url":"https://github.com/MatthewLarner/cross-domain-storage","tags":["javascript"],"install":[{"cmd":"npm install cross-domain-storage","lang":"bash","label":"npm"},{"cmd":"yarn add cross-domain-storage","lang":"bash","label":"yarn"},{"cmd":"pnpm add cross-domain-storage","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM default export. CJS requires default import workaround: const CrossDomainStorage = require('cross-domain-storage').default.","wrong":"const CrossDomainStorage = require('cross-domain-storage')","symbol":"CrossDomainStorage","correct":"import CrossDomainStorage from 'cross-domain-storage'"},{"note":"Named export does not exist; only default export.","wrong":"import { CrossDomainStorage } from 'cross-domain-storage'","symbol":"CrossDomainStorage","correct":"import CrossDomainStorage from 'cross-domain-storage'"},{"note":"CJS require returns an object with default property in ESM interop. Older bundlers may need the fallback.","wrong":"const CrossDomainStorage = require('cross-domain-storage')","symbol":"CrossDomainStorage","correct":"const CrossDomainStorage = require('cross-domain-storage').default || require('cross-domain-storage')"}],"quickstart":{"code":"import CrossDomainStorage from 'cross-domain-storage';\n\nconst storage = new CrossDomainStorage({\n  type: 'iframe',\n  origin: 'https://parent.example.com',\n  path: '/cross-domain-storage.html',\n});\n\nstorage.on('connected', () => {\n  storage.set('key', { value: 'test', ttl: 3600 });\n  storage.get('key', (err, data) => {\n    if (err) console.error(err);\n    else console.log('Retrieved:', data);\n  });\n});\n\nstorage.on('error', console.error);","lang":"javascript","description":"Creates an iframe-based cross-domain storage, sets a key with TTL, and retrieves it on connection."},"warnings":[{"fix":"Ensure origin string matches parent window (e.g., 'https://example.com:443').","message":"The 'origin' must exactly match the target window origin, including protocol and port.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Encrypt data manually before setting, or use a secure origin with HTTPS.","message":"Data is not encrypted; sensitive values are transmitted via postMessage in plaintext.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Implement a manual timeout wrapper around the get method.","message":"The library has no built-in timeout for get requests; if the target window doesn't respond, the callback never fires, causing silent failures.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Place cross-domain-storage.html (from /dist) on the remote origin, or host it yourself.","message":"The 'path' option must point to an HTML file that includes the library's helper script on the target origin.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'2016':29 'across':15 'api':43 'browser':12 'browser-localstorag':11 'cross':2,6,34 'cross-domain-storag':1,5 'cross-origin':33 'depend':52 'domain':3,7 'enabl':10 'extern':51 'ideal':30 'ifram':45 'javascript':53 'lightweight':49 'localstorag':13 'low':23 'low-mainten':22 'mainten':24 'messag':48 'minim':42 'new':26 'origin':35 'parent/child':18 'persist':36 'postmessag':21 'releas':27 'server':39 'server-sid':38 'setup':41 'share':14 'side':40 'simpl':32 'sinc':28 'storag':4,8 'subdomain':16 'use':44 'v2.0.7':9 'via':20 'window':19,47 'without':37","created_at":"2026-06-07T16:51:03.092126+00:00","updated_at":"2026-06-07T16:51:03.092126+00:00","problems":[{"fix":"Check that the origin includes the correct protocol, host, and port (e.g., 'http://localhost:8080').","cause":"The origin option does not match the actual origin of the target window.","error":"Uncaught DOMException: Blocked a frame with origin \"http://localhost:3000\" from accessing a cross-origin frame."},{"fix":"Use import CrossDomainStorage from 'cross-domain-storage' (ESM) or const CrossDomainStorage = require('cross-domain-storage').default (CJS).","cause":"Default import in ESM or missing .default in CJS.","error":"TypeError: CrossDomainStorage is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/MatthewLarner/cross-domain-storage#readme","github":"https://github.com/MatthewLarner/cross-domain-storage","docs":null,"changelog":null,"pypi":null,"npm":"cross-domain-storage","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}