Skip to main content
npm · v2.0.0
Vali-Storages

Vali-Storages

// browser storage, encrypted & typed.

— Install
$bun add vali-storages
or
$npm install vali-storages
AES-256Encryption level
3Key sizes
4Time units
100%TypeScript typed
0Dependencies
— Features

Everything you need

A clean, fully typed async API on top of localStorage and sessionStorage.

SECURITY
🔐

AES-GCM Encryption

Military-grade AES-128, 192 or 256-bit encryption via the Web Crypto API. Values encrypt on write, decrypt on read — transparently.

LIFECYCLE

TTL Expiration

Configure item lifetimes in seconds, minutes, hours or days. Expired items are purged automatically on the next read.

TYPESCRIPT
🔒

Type-Safe API

Use createTypedStorage<Schema>() to enforce compile-time type checking on keys and values. Catch errors before they happen.

REALTIME
📡

Cross-Tab Sync

React to storage mutations from other browser tabs via onChange. Build reactive multi-tab apps with zero boilerplate.

ISOLATION
🏷

Namespacing

Prefix-based isolation keeps storage instances completely independent. clear() and size() only affect their own domain.

PERFORMANCE
🧩

Batch Operations

Read and write multiple keys in a single call with setItems, getItems and getAll. Parallel execution under the hood.

— Examples

See it in action

From basic usage to AES-256 encryption, strict typing and cross-tab sync.

storage.ts
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();

Ready to start?

Explore the full docs and take your storage management to the next level.