Zero-dependency universal storage plugin providing a unified API for all storage operations across web, Android, and iOS platforms
npm install strata-storage---
One API. Every Storage. Everywhere.
Zero-dependency universal storage plugin providing a unified API for all storage operations across web, Android, and iOS platforms.
``bash`
npm install strata-storage
typescript
import { storage } from 'strata-storage';// Works immediately - no setup, no providers, no initialization!
await storage.set('user', { name: 'John', age: 30 });
const user = await storage.get('user');
`$3
Check out our React + Capacitor example app that demonstrates all features:
- All storage adapters working correctly
- Web, Android, and iOS platform support
- Real-time testing interface
- Complete error handling
Run the example:
`bash
cd examples/react-capacitor-app
yarn install
yarn start # For web
npx cap run android # For Android
npx cap run ios # For iOS
`$3
`typescript
import { storage } from 'strata-storage';
import { registerCapacitorAdapters } from 'strata-storage/capacitor';// Only if you need native features
if (window.Capacitor) {
await registerCapacitorAdapters(storage);
}
// Use native storage when available
await storage.set('secure-data', 'secret', { storage: 'secure' });
`$3
`typescript
import { storage } from 'strata-storage';
import { enableFirebaseSync } from 'strata-storage/firebase';// Only if you need cloud sync
if (needCloudSync) {
await enableFirebaseSync(storage, {
apiKey: 'your-api-key',
projectId: 'your-project-id',
firestore: true
});
}
// Works offline-first, syncs when online
await storage.set('data', value, { storage: 'firestore' });
`✨ Features
$3
- ✅ Zero Dependencies - No runtime dependencies, pure implementation
- ✅ Provider-less Architecture - No providers, contexts, or wrappers needed (like zustand)
- ✅ Works Everywhere - React, Vue, Angular, Vanilla JS, Node.js - same API
- ✅ Zero Configuration - Import and use immediately, no setup required
- ✅ Opt-in Complexity - Start simple, add features only when needed
- ✅ Dynamic Provider Loading - Providers load only when used, keeping bundle small
- ✅ Universal API - Single interface for all storage types
- ✅ Cross-Platform - Web, iOS, Android support
- ✅ TypeScript - Full type safety and IntelliSense
- ✅ Auto Fallback - Intelligent storage selection$3
- ✅ Memory - Fast in-memory storage
- ✅ LocalStorage - Persistent browser storage
- ✅ SessionStorage - Session-based browser storage
- ✅ IndexedDB - Large-scale browser database
- ✅ Cookies - HTTP cookie storage
- ✅ Cache API - Service worker cache storage
- ✅ Capacitor Preferences - Native mobile preferences
- ✅ SQLite - Mobile SQL database
- ✅ Secure Storage - Keychain (iOS) / Encrypted SharedPreferences (Android)
- ✅ Filesystem - File-based storage$3
- ✅ Encryption - AES-GCM encryption with Web Crypto API
- ✅ Compression - LZ-string compression algorithm
- ✅ Cross-Tab Sync - Real-time synchronization across tabs
- ✅ Query Engine - MongoDB-like queries for filtering data
- ✅ TTL Support - Automatic expiration with sliding TTL
- ✅ Migration System - Version-based data migrations
- ✅ Framework Integrations - React, Vue, Angular📖 Basic Usage
`typescript
import { storage } from 'strata-storage';// No initialization needed - works immediately!
// Simple usage
await storage.set('key', 'value');
const value = await storage.get('key');
await storage.remove('key');
await storage.clear();
// Advanced options
await storage.set('key', value, {
storage: 'indexedDB', // Choose specific storage
ttl: 3600000, // Expire in 1 hour
encrypt: true, // Encrypt this value
compress: true, // Compress if beneficial
tags: ['user-data'], // Tag for grouping
metadata: { // Attach metadata
version: 1,
source: 'api'
}
});
// Query data with MongoDB-like syntax
const results = await storage.query({
tags: { $in: ['user-data'] },
'value.age': { $gte: 18 },
'metadata.version': 1
});
// Subscribe to changes
storage.subscribe((change) => {
console.log(
${change.key} changed from ${change.oldValue} to ${change.newValue});
});// Check storage size
const size = await storage.size();
console.log(
Using ${size.total} bytes for ${size.count} items);
``Production Ready - All major features implemented:
- ✅ Zero-dependency architecture
- ✅ Provider-less design (like Zustand)
- ✅ All web storage adapters (localStorage, IndexedDB, etc.)
- ✅ Complete Capacitor integration (iOS/Android)
- ✅ Native implementations (iOS Swift, Android Java)
- ✅ Advanced features (encryption, compression, sync, query, TTL)
- ✅ Framework integrations (React, Vue, Angular)
- ✅ Comprehensive documentation
- ✅ Full TypeScript support
- ✅ Example application with all features
Apache 2.0 - See LICENSE and License Details
---
Created by Ahsan Mahmood