blog.logrocket.com
Offline-first frontend apps in 2025: IndexedDB and SQLite in the ...
Excerpt
**Disadvantages:** - The low-level API is verbose and historically callback-heavy (libraries such as `idb` help a lot) - No JOINs or advanced relational query capabilities - Subtle cross-browser differences and quirks - Schema changes require careful versioning and migration logic - More complex than `localStorage`, but necessary for serious application data … ### SQLite in the browser via WebAssemblybAOne of the most significant changes is running SQLite directly in the browser through WebAssembly. Projects such as `sql.js` and `wa-sqlite` have matured to the point where you can run a full SQL database, with millions of rows, entirely on the client. This is a major shift: - You can use standard SQL for queries and relational modeling - Business logic and data transformations can run locally - The database can live in memory or persist to IndexedDB or the Origin Private File System (OPFS) … ### Conflict resolution in multi-device appsviThe hardest problem is conflicting edits. For example, a user might edit the same note on both their phone and laptop while both are offline. When each device syncs, which version should win? Options include: - Last-write-wins based on timestamps or version counters - Operational transforms (OT), which merge edits at the operation level - CRDTs, which mathematically guarantee convergence - Manual conflict resolution flows where the user chooses the correct version … - Financial operations - Inventory and stock allocation - Ticketing and booking systems For these, you might combine patterns: - Optimistic reads and non-critical writes - Strongly consistent writes for critical operations that must be confirmed by the server before committing locally … Your app needs to handle quota-exceeded errors gracefully. Useful strategies include: - Pruning old or derived data - Compressing large payloads where appropriate - Giving users a UI to clear cached content or reduce offline storage … #### Prioritize user control and transparencynsSilent syncing without any visibility can erode trust. Expose enough state that users feel in control: - Visible sync status (syncing, up to date, conflicts) - A manual “sync now” action for power users - A way to see pending operations in the queue - Settings to manage offline storage Users are more tolerant of edge cases when they understand what is happening.
Related Pain Points
Conflict resolution challenges in offline-first multi-device apps
7Implementing conflict resolution for offline-first applications where users edit the same data across multiple devices simultaneously is difficult. Developers must choose between last-write-wins, operational transforms, CRDTs, or manual resolution flows.
IndexedDB verbose API and lack of relational query capabilities
5IndexedDB's low-level API is verbose and historically callback-heavy, requiring external libraries for usability. It lacks JOINs and advanced relational query capabilities, making complex data queries difficult.
Storage quota management and quota-exceeded error handling in offline apps
5Browser-based offline-first applications must gracefully handle storage quota-exceeded errors by pruning data, compressing payloads, or allowing users to clear cached content. Managing storage limits adds complexity to application logic.
IndexedDB cross-browser differences and schema versioning complexity
4IndexedDB exhibits subtle cross-browser differences and quirks. Schema changes require careful versioning and migration logic, adding complexity compared to simpler storage solutions.