It's rare to see offline support in a web app for a few reasons:
LocalStorage is easy to use but too limited at 50Mb.
WebSQL got deprecated by FireFox because of secuirty issues years ago ( albeit is still somewhat supported in Chrome ).
The FileSystem API looked promising, and then google killed it.
IndexedDb is the only option, it's slow on writes, therefore requiring major hacks like absurd-sql to be performant.
It's also old, written before ES6, needs lots of boilerplate, but it does actually work.
https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_A...
Even then however there is a limit of 2GB of persistent storage it can use, which is workable but still:
Some versions of Safari are known to delete IndexedDB after 1 week because of power savings.
Chrome does not allow it unless you either accept notifications from that domain and/or pass a certain lighthouse score (these reasons are anectodal and not well-documented).
So yeah it's a mess, and a bit sad considering it will take years to ratify a better standard for this, but not impossible to do.
Also annoying to know that internally your browser is actually using sqlite under-the-hood anyway.
Web based game engines (i.e. XREngine) are able to get by with IndexedDB i think, and apps like https://github.com/actualbudget/actual created by the author of absurd-sql are good codebases to follow as example.
LocalStorage is easy to use but too limited at 50Mb.
WebSQL got deprecated by FireFox because of secuirty issues years ago ( albeit is still somewhat supported in Chrome ).
The FileSystem API looked promising, and then google killed it.
IndexedDb is the only option, it's slow on writes, therefore requiring major hacks like absurd-sql to be performant. It's also old, written before ES6, needs lots of boilerplate, but it does actually work. https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_A...
Even then however there is a limit of 2GB of persistent storage it can use, which is workable but still:
Some versions of Safari are known to delete IndexedDB after 1 week because of power savings. Chrome does not allow it unless you either accept notifications from that domain and/or pass a certain lighthouse score (these reasons are anectodal and not well-documented).
So yeah it's a mess, and a bit sad considering it will take years to ratify a better standard for this, but not impossible to do. Also annoying to know that internally your browser is actually using sqlite under-the-hood anyway.
Web based game engines (i.e. XREngine) are able to get by with IndexedDB i think, and apps like https://github.com/actualbudget/actual created by the author of absurd-sql are good codebases to follow as example.
WebAssembly based sqlite is coming along nicely too. https://sqlite.org/wasm/doc/tip/about.md.
I am personally working on an offline-capable ML product using pyscript, svelte & indexedDb and it's been a painful ammount of fun so far.