strata-storage
v2.4.3
Published
Zero-dependency universal storage plugin providing a unified API for all storage operations across web, Android, and iOS platforms
Downloads
25
Maintainers
Readme
Strata Storage
📚 Documentation
Getting Started
- Installation - Installation and setup
- Quick Start Guide - Get running in minutes
- Configuration - Configuration options
Core Documentation
- API Reference - Complete API documentation
- Core API - Main Strata class
- Type Definitions - TypeScript types
- Error Handling - Error types and handling
Storage Adapters
- Web Adapters - Browser storage
- Capacitor Adapters - Native storage
Advanced Features
- Encryption - Data encryption guide
- Compression - Data compression
- TTL Management - Auto-expiration
- Cross-Tab Sync - Real-time synchronization
- Query Engine - MongoDB-like queries
- Migrations - Data migration system
Platform Guides
- Web Platform - Browser-specific features
- iOS Platform - iOS implementation
- Android Platform - Android implementation
- Capacitor - Capacitor integration
Common Patterns
- Caching Strategies - Caching best practices
- Session Management - User session handling
Examples
- Basic Usage - Simple examples
- React Integration - React hooks and providers
- Vue Integration - Vue composables
- Angular Integration - Angular services
- Authentication - User authentication
- Shopping Cart - E-commerce example
- Form Persistence - Form data saving
- Offline Support - Offline-first apps
- All Examples - Complete examples list
Resources
- GitHub - Source code
- NPM - Package registry
- Example App - Full demo application
- Contributing - How to contribute
- Support - Get help
- Security - Report vulnerabilities
One API. Every Storage. Everywhere.
Zero-dependency universal storage plugin providing a unified API for all storage operations across web, Android, and iOS platforms.
🚀 Quick Start
npm install strata-storageProvider-less Usage (Zero Setup)
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');Complete Example App
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:
cd examples/react-capacitor-app
yarn install
yarn start # For web
npx cap run android # For Android
npx cap run ios # For iOSWith Capacitor (Optional)
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' });With Firebase (Optional)
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
Core Features
- ✅ 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
Storage Adapters
- ✅ 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
Advanced Features
- ✅ 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
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`);🎯 Why Strata Storage?
Provider-less Architecture
Like Zustand, Strata Storage works without providers, contexts, or wrappers. Just import and use - no setup required.
Zero Dependencies
Truly zero runtime dependencies. Everything is implemented from scratch for maximum control and minimal bundle size.
Universal Compatibility
- One API - Same code works on Web, iOS, and Android
- Any Framework - Works with React, Vue, Angular, or vanilla JavaScript
- TypeScript First - Full type safety and excellent IntelliSense
- Tree-Shakeable - Only bundle what you use
Intelligent Storage Selection
Automatically selects the best available storage based on:
- Platform capabilities
- Data size and type
- Performance requirements
- Persistence needs
Enterprise Ready
- Encryption - Built-in AES-GCM encryption
- Compression - Automatic data compression
- TTL/Expiration - Auto-cleanup of expired data
- Sync - Real-time cross-tab/device synchronization
- Migrations - Version-based data migrations
- Querying - MongoDB-like query engine
🏗 Project Status
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
📄 License
Apache 2.0 - See LICENSE and License Details
Quick Summary:
- ✅ Free for commercial use
- ✅ Modify and distribute
- ✅ Patent protection included
- ⚠️ Must keep attribution
- ❌ No warranty provided
Created by Ahsan Mahmood
