Opal Editor uses a sophisticated local-first storage architecture that keeps all your data on your device with zero backend dependencies. The storage system provides multiple storage backends optimized for different use cases.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/rbbydotdev/opal/llms.txt
Use this file to discover all available pages before exploring further.
Storage Backends
Opal Editor implements three primary storage backends, each with specific advantages:IndexedDB Storage
Best for: Maximum browser compatibility and general use IndexedDB storage uses the Lightning FS library to provide a virtual file system backed by IndexedDB, the standard browser database API.- Works in all modern browsers
- No permissions required
- Stores data as key-value pairs
- Supports files up to browser limits (typically 50MB-100MB+)
- Persists across browser sessions
- Uses
@isomorphic-git/lightning-fsfor file system operations - Data stored in browser’s IndexedDB under workspace GUID
- Asynchronous operations with Promise-based API
- Automatic garbage collection and compaction
OPFS Storage (Origin Private File System)
Best for: Performance and large files OPFS is a newer browser API that provides direct file system access with better performance characteristics than IndexedDB.- Native file system performance
- Better suited for large files and workspaces
- Lower memory overhead
- Direct disk access (outside main thread)
- Isolated per-origin storage
- Requires browser support (Chrome 102+, Edge 102+, Safari 15.2+)
- Namespaced under workspace GUID for isolation
- Supports synchronous operations in workers
- Automatic persistence without quota prompts
Memory Storage
Best for: Temporary workspaces and testing Memory-based storage keeps data in RAM, useful for temporary workspaces that don’t need persistence.Storage Architecture
Disk Abstraction
All storage backends implement a commonDisk interface, allowing the editor to work with any storage type seamlessly:
File Tree Indexing
Opal maintains an in-memory file tree index for fast navigation:Data Persistence
Opal uses Dexie.js to manage structured data in IndexedDB:- Workspace configurations
- Disk type and settings
- Build and deployment history
- Document edit history
- Remote authentication tokens
Storage Events
The storage system emits events for file changes, enabling reactive updates:Performance Optimizations
Mutex-based Concurrency
All file operations are protected by mutexes to prevent race conditions:Lazy Loading
The file tree index is cached but file contents are loaded on-demand:Batched Operations
Multiple file operations can be batched for better performance:Storage Limits
IndexedDB
- Typically 50MB minimum per origin
- Can request up to 60% of total disk space
- Subject to browser quota management
OPFS
- Typically larger quota than IndexedDB
- Better suited for large workspaces
- Persistent storage without prompts
Best Practices
Choose the right storage type
Choose the right storage type
- Use OPFS for large workspaces with many images
- Use IndexedDB for maximum compatibility
- Use Memory storage for temporary workspaces
Monitor storage usage
Monitor storage usage
Check available storage periodically:
Handle quota errors gracefully
Handle quota errors gracefully
Storage operations may fail when quota is exceeded:
Advanced Usage
Custom Disk Implementation
You can implement custom storage backends by extending theDisk class: