{"id":49700,"library":"web-browser-storage","title":"web-browser-storage","description":"A wrapper around localStorage providing JSON value handling, caching, and a consistent Storage interface. Version 0.1.14 is current. The library offers LocalStorage (real browser storage with availability checks), MemoryStorage (for testing, with optional shared instances), and CachedStorage (buffers writes and flushes on delay/tab blur). It differs from similar libraries by including onExternalChange listeners and byte size reporting. Ideal for apps needing robust browser storage with testability and performance optimizations.","status":"active","version":"0.1.14","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","frontend","storage","browser"],"install":[{"cmd":"npm install web-browser-storage","lang":"bash","label":"npm"},{"cmd":"yarn add web-browser-storage","lang":"bash","label":"yarn"},{"cmd":"pnpm add web-browser-storage","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Named export, not default. Must use destructuring.","wrong":"import LocalStorage from 'web-browser-storage'","symbol":"LocalStorage","correct":"import { LocalStorage } from 'web-browser-storage'"},{"note":"ESM named import. CJS require works but is not tree-shakable.","wrong":"const MemoryStorage = require('web-browser-storage').MemoryStorage","symbol":"MemoryStorage","correct":"import { MemoryStorage } from 'web-browser-storage'"},{"note":"Single entry point. No subpath exports.","wrong":"import { CachedStorage } from 'web-browser-storage/cached'","symbol":"CachedStorage","correct":"import { CachedStorage } from 'web-browser-storage'"}],"quickstart":{"code":"import { LocalStorage } from 'web-browser-storage'\n\nconst storage = new LocalStorage()\nstorage.set('user', { name: 'Alice', age: 30 })\nconst user = storage.get('user')\nconsole.log(user.name) // 'Alice'\n\nif (!LocalStorage.isAvailable()) {\n  console.warn('localStorage is disabled')\n}\n\nstorage.onExternalChange(({ key, value, prevValue }) => {\n  console.log(`Key ${key} changed from ${JSON.stringify(prevValue)} to ${JSON.stringify(value)}`)\n})","lang":"javascript","description":"Shows basic usage: store and retrieve JSON, check localStorage availability, and listen for external changes."},"warnings":[{"fix":"Check availability by wrapping localStorage access in try/catch instead.","message":"The isAvailable() static method may be deprecated in future versions.","severity":"deprecated","affected_versions":"<=0.1.14"},{"fix":"Use { stringifyStoredValues: false } in constructor to keep types intact.","message":"MemoryStorage stringifies values by default (simulating localStorage). Date objects become strings.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use flush() manually or rely on tab blur event. Not suitable for critical data.","message":"CachedStorage delays writes; data loss risk if browser crashes before flush.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.1.14':20 'app':64 'around':7 'avail':31 'blur':48 'browser':3,28,67,77 'buffer':42 'byte':59 'cach':13 'cachedstorag':41 'check':32 'consist':16 'current':22 'delay/tab':47 'differ':50 'flush':45 'frontend':75 'handl':12 'ideal':62 'includ':55 'instanc':39 'interfac':18 'javascript':74 'json':10 'librari':24,53 'listen':57 'localstorag':8,26 'memorystorag':33 'need':65 'offer':25 'onexternalchang':56 'optim':73 'option':37 'perform':72 'provid':9 'real':27 'report':61 'robust':66 'share':38 'similar':52 'size':60 'storag':4,17,29,68,76 'test':35 'testabl':70 'valu':11 'version':19 'web':2 'web-browser-storag':1 'wrapper':6 'write':43","created_at":"2026-06-07T17:03:09.618678+00:00","updated_at":"2026-06-07T17:03:09.618678+00:00","problems":[{"fix":"Check availability with LocalStorage.isAvailable() before operations.","cause":"Calling localStorage methods when localStorage is disabled (e.g., private browsing in some browsers).","error":"TypeError: localStorage is not available"},{"fix":"Handle with try/catch or use LocalStorage constructor option 'onFull'.","cause":"Exceeding browser storage limit (usually 5-10 MB).","error":"QuotaExceededError: Failed to execute 'setItem' on 'Storage'"},{"fix":"Upgrade to >=0.1.0 where all classes are named exports.","cause":"Using an older version (<0.1.0) that had different export names.","error":"import { LocalStorage } from 'web-browser-storage' did not export 'LocalStorage'"}],"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://gitlab.com/catamphetamine/web-browser-storage#readme","github":null,"docs":null,"changelog":null,"pypi":null,"npm":"web-browser-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}}