bun add vali-storagesnpm install vali-storagesA clean, fully typed async API on top of localStorage and sessionStorage.
Military-grade AES-128, 192 or 256-bit encryption via the Web Crypto API. Values encrypt on write, decrypt on read — transparently.
Configure item lifetimes in seconds, minutes, hours or days. Expired items are purged automatically on the next read.
Use createTypedStorage<Schema>() to enforce compile-time type checking on keys and values. Catch errors before they happen.
React to storage mutations from other browser tabs via onChange. Build reactive multi-tab apps with zero boilerplate.
Prefix-based isolation keeps storage instances completely independent. clear() and size() only affect their own domain.
Read and write multiple keys in a single call with setItems, getItems and getAll. Parallel execution under the hood.
From basic usage to AES-256 encryption, strict typing and cross-tab sync.
import { ValiStorages } from 'vali-storages';
const storage = new ValiStorages();
// Write & read
await storage.setItem('username', 'felipe');
const name = await storage.getItem<string>('username');
// → 'felipe'
// Check, count, batch read
storage.has('username'); // → true
storage.size(); // → 1
const all = await storage.getAll();// → { username: 'felipe' }
// Cache pattern — compute only if missing
const data = await storage.getOrSet('config', async () => {
return await fetchConfigFromAPI();
});
// Remove & clean up
storage.removeItem('username');
storage.removeExpired();
storage.clear();Explore the full docs and take your storage management to the next level.