BREAKING CHANGES
Switch to ES modules and named exports
The WebStorage
module is now exclusively available as an ES module (ESM), aligning with the modern JavaScript module standard. Additionally, it is no longer the default export — you must import it using a named import.
v2.x.x
import WebStorage from '@georapbox/web-storage';
v3.x.x
import { WebStorage } from '@georapbox/web-storage';
API methods return [value, error] tuples
All API methods now return [value, error]
tuple-like values instead of accepting error callbacks. This allows developers to handle errors in a clean, synchronous style without using try/catch
or providing callbacks. For example:
v2.x.x
const value = storage.getItem('key', value, (err) => {
console.error(err);
});
v3.x.x
const [value, error] = storage.getItem('key', value);
if (error) {
console.error(error);
}
Removed noop storage fallback
In previous versions, if localStorage
or sessionStorage
was unavailable (e.g., due to privacy settings or Safari private mode), a silent in-memory fallback was used that mimicked the Storage API. This allowed methods like setItem()
to return success even though no actual data was stored.
This behavior has been removed to improve transparency and correctness. As of v3.0.0:
- No fallback is used.
- Errors are captured and returned via the
[_, error]
tuple-like value. - Developers can use
WebStorage.isAvailable()
for feature detection, or gracefully handle errors based on method output.
This ensures failures are explicit and prevents false assumptions about persistence.
NEW FEATURES
Type declarations for TypeScript
Export type declaration files (.d.ts
) for TypeScript users, ensuring better type safety and autocompletion support in TypeScript projects.
INTERNAL CHANGES
- Update Node.js version requirement and dev dependencies to the latest versions.
- Drop Jest in favor of @web/test-runner and Playwright for testing.
- Drop rollup in favor of esbuild for bundling.