LocalStorageX is a polyfill for the W3C localStorage API backed by a more reliable storage mechanism.
For one, It resolves the painful behaviour of iOS WKWebView that deletes localStorage data, without warning, and as it sees fit - making implementations using the standard localStorage API break.
At its foundation it uses the localForage project (https://github.com/localForage/localForage)
- Browsers (Desktop Chrome, Android Chrome, iOS Safari)
- Cordova (Android, iOS)
npm i localstoragex
LocalStorageX exports a singleton (static) class. Thus no instantiation is required.
import { storage } from "LocalStorageX";
...
await storage.init();
window.localStorage.override(); //true
...
npm run build
npm run link
npm run test
Submit a PR or log an issue
- Attempts to reload localstoragex in the event of a localforage error due to e.g. clearing browser / app cache while app is running
- Loads current localStorage (if any) into localstoragex on init
- Init only yields once device (cordova) or document (web) is ready
- Initial