Installation
Usage
Configuration
Global Setup
Configuration Options
Name of the IndexedDB database
Database version number. Increment when schema changes.
Array of table (object store) names to create
Tables to delete during upgrade
Custom upgrade handler for advanced schema migrations
Per-Observable Options
When usingpersist on individual observables, you can specify additional IndexedDB options:
Prefix to namespace data within the same table. Useful for multi-tenant apps.
Store a single item instead of a collection. The item is stored with this ID.
Plugin API
The IndexedDB plugin implements theObservablePersistPlugin interface:
initialize()
loadTable()
getTable()
set()
getMetadata()
setMetadata()
deleteTable()
deleteMetadata()
Examples
Basic Setup
Large Dataset
Multi-Tenant
Single Item Storage
Schema Versioning
Custom Indexes
Offline-First App
Clear All Data
Storage Format
IndexedDB stores objects withid as the key path:
Performance
IndexedDB is faster than localStorage for large datasets:Browser Support
IndexedDB is supported in all modern browsers. The plugin gracefully handles environments where IndexedDB is unavailable:Best Practices
- Configure globally: Set up IndexedDB once at app startup
- Version carefully: Only increment version when schema changes
- Use for large data: Better than localStorage for > 1MB
- Plan your tables: Each persisted observable should map to a table
- Handle initialization: IndexedDB setup is async, wait for
isLoaded
Migration from localStorage
See Also
- localStorage Plugin - For smaller datasets
- AsyncStorage Plugin - For React Native
- synced() - Create synced observables
- configureObservableSync() - Global configuration