Local-first data persistence with IndexedDB and OPFS
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.
Best for: Maximum browser compatibility and general useIndexedDB storage uses the Lightning FS library to provide a virtual file system backed by IndexedDB, the standard browser database API.
// From IndexedDbDisk.tsclass IndexedDbDisk extends Disk { constructor(guid: string, indexCache?: TreeDirRootJType) { const lightningFs = new LightningFs(); const fs = lightningFs.promises; // Creates a virtual filesystem in IndexedDB }}
Key features:
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
Technical details:
Uses @isomorphic-git/lightning-fs for file system operations
Data stored in browser’s IndexedDB under workspace GUID
Best for: Performance and large filesOPFS is a newer browser API that provides direct file system access with better performance characteristics than IndexedDB.
// From OpFsDisk.tsclass OpFsDisk extends Disk { constructor(guid: string) { // Gets native file system handle const rootDir = await navigator.storage.getDirectory(); const patchedOPFS = new PatchedOPFS(rootDir); const fs = new OPFSNamespacedFs(patchedOPFS, `/${guid}`); }}
Key features:
Native file system performance
Better suited for large files and workspaces
Lower memory overhead
Direct disk access (outside main thread)
Isolated per-origin storage
Technical details:
Requires browser support (Chrome 102+, Edge 102+, Safari 15.2+)