A browser storage adapter that automatically falls back through localStorage, sessionStorage, cookies, and in-memory storage, depending on what is available and not throwing exceptions (e.g., in private browsing mode). Current stable version is 5.0.0. Maintained infrequently. Key differentiator: handles private browsing and quota errors gracefully where native localStorage would throw, and provides a unified API across all backends. Fully typed with TypeScript definitions.
npm install local-storage-fallbackNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Import and use local-storage-fallback as a drop-in replacement for window.localStorage with automatic fallback through sessionStorage, cookies, and memory.
Keep stored values under 4KB, or use sessionStorage/localStorage if available. Monitor for cookie size limits.
If you need persistence across full page loads, avoid falling back to MemoryStorage. Ensure localStorage or sessionStorage is available first.
Use require('local-storage-fallback') directly, not require('local-storage-fallback').storage.Wrap storage.getItem()/setItem() in try-catch if you use the module directly; the fallback may still throw if all backends fail.
Use conditional imports or mock for server-side environments.
Ensure the UMD script is loaded before calling window.localStorageFallback.setItem(). If using a module bundler, import the module instead.
Change to const storage = require('local-storage-fallback'); then use storage.setItem().Serve from a proper http/https origin. If not possible, ensure the module is used with fallback that includes memory storage (but data will not persist).
No dependency data recorded yet.