@zellvora/ng-storage
v0.1.1
Published
Enterprise Angular 21 Signal-first storage abstraction with localStorage, sessionStorage, IndexedDB, cookies, encryption, compression, versioning, and cross-tab sync.
Downloads
88
Readme
@zellvora/ng-storage
Enterprise Angular 21 Signal-first unified storage abstraction supporting localStorage, sessionStorage, IndexedDB, cookies, and encrypted storage with automatic serialization, compression, TTL, versioning, encryption, and cross-tab synchronization.
Features
- 100% Signal-based - All APIs return reactive Signals
- Multi-adapter - localStorage, sessionStorage, IndexedDB, cookies, memory, custom
- Encryption - Built-in AES-GCM encryption with key rotation
- Compression - Automatic deflate compression for large values
- TTL & Expiration - Automatic expiration handling
- Versioning - Schema versioning with automatic migrations
- Cross-tab Sync - Synchronize storage across browser tabs
- Backup/Restore - Built-in backup and restore functionality
- SSR Compatible - Hydration-aware storage adapter
- Zoneless Ready - Compatible with zoneless change detection
- Type Safe - Full TypeScript support with generics
Installation
npm install @zellvora/ng-storageQuick Start
import { provideZvStorage, ZvStorageService } from '@zellvora/ng-storage';
// app.config.ts
export const appConfig: ApplicationConfig = {
providers: [
provideZvStorage({
defaultAdapter: 'localStorage',
encryption: { enabled: true },
compression: { enabled: true, threshold: 1024 },
sync: { enabled: true }
})
]
};
// my.component.ts
@Component({ ... })
export class MyComponent {
storage = inject(ZvStorageService);
// Create a reactive storage signal
user = this.storage.createSignal<User>('user', { encrypt: true });
get userName() { return this.user.value()?.name; }
get isLoading() { return this.user.loading(); }
async saveUser(user: User) {
await this.user.set(user);
}
}Adapters
- localStorage - Web Storage API (synchronous, ~5-10MB)
- sessionStorage - Session-only storage (synchronous, ~5-10MB)
- IndexedDB - Async NoSQL database (asynchronous, gigabytes)
- cookies - HTTP cookies (synchronous, ~4KB)
- memory - In-memory storage (for testing, no persistence)
- secure - Wrapper for any adapter with encryption
- SSR - Hydration-aware adapter for server-side rendering
- custom - Implement IStorageAdapter for custom backends
Services
ZvStorageService- Main unified APIZvEncryptionService- AES encryption/decryptionZvCompressionService- Compression utilitiesZvMigrationService- Schema versioning and migrationsZvSyncService- Cross-tab synchronizationZvBackupService/ZvRestoreService- Backup/restore
Documentation
See projects/ng-storage/src/lib for complete implementation details.
