Detects whether web storage (localStorage or sessionStorage) is available and functional in the browser. Version 1.1.0 is the current stable release, with infrequent updates. It implements the feature detection algorithm recommended by MDN, handling edge cases like Safari private browsing where storage exists but throws on writes. Ships TypeScript definitions. Minimal zero-dependency package.
npm install storage-availableNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Detect availability of localStorage and sessionStorage with recommended MDN method.
Wrap storage writes in try/catch as backup.
Only call with 'localStorage' or 'sessionStorage'.
Consider using a try/catch write test as a more comprehensive check on older iOS.
Only import in browser bundles or provide a polyfill for Node.js tests.
Use `as (storage: 'localStorage' | 'sessionStorage') => boolean` or create a local type.
Replace `import { storageAvailable }` with `import storageAvailable`Only call storageAvailable in browser context or provide polyfills for testing.
Check if storageAvailable exists before calling, or use a try/catch.
No dependency data recorded yet.