A lightweight (~1kB gzipped), fully-typed wrapper around the Web Storage API (localStorage / sessionStorage) with expiration support, optional key namespacing, and change event listeners. Version 6.1.0 is the latest stable release, actively maintained on GitHub. Unlike raw storage APIs, localit handles serialization automatically, supports expiration strings like '5m' or '2h', and allows listening to key changes via an `on` method. It requires no external dependencies and ships TypeScript type definitions.
npm install localitNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates setting with expiration, typed get, change listener, removal, and family-based namespacing with clearFamily.
Use the native 'storage' event or a polyfill for cross-tab synchronization.
Purge expired entries by calling `get` on them or periodically clearing storage with `bust()`.
Use `localit.remove('key', { family: 'familyName' })` to remove a namespaced key.Change to `import { localit } from 'localit'`.Use valid format: e.g., '1d' for 1 day. Or pass a Date object.
Replace `import localit from 'localit'` with `import { localit } from 'localit'`.Wrap usage in a try-catch or check `typeof window !== 'undefined'` before calling localit methods.
Update to v6.1.0: `npm install localit@latest`. For v5, use `import localit from 'localit'`.
Ensure the `family` config matches between `set` and `get`. Or omit family entirely if not needed.
No dependency data recorded yet.