Description
Description
Ability to set custom headers - so I can use OPFS and SQLite WASM backed by OPFS
Platforms
- iOS
- Android
- Web
Request or proposed solution
I am trying to get the SQLite WASM build backed by OPFS working, and ran into the issue where it requires certain headers be set to work:
- https://sqlite.org/wasm/doc/trunk/persistence.md#coop-coep
- https://www.npmjs.com/package/@sqlite.org/sqlite-wasm (has example on how these headers are configured with vite, which is how I have OPFS working on Web - but on iOS / Android? there's no equivalent)
After searching I couldn't find a way to do this in Capacitor. It seems that this issue has cropped up a few times, and I think the use of the official SQLite WASM build, and OPFS will become more frequent.
It also seems like a reasonable successor to jeep-sqlite. If I understand the history of the SQLite+WASM library space - the approach of putting SQLite into IndexedDB was a sort of hack to get around not having a place to store the SQLite db file on the web client, and has some downsides (performance and ACID compliance from what I've read). OPFS would resolve those - and open up the possibility of building doing "local-first" type architectures where all platforms use the same configuration for accessing a local SQLite database.
Related issues (Closed as completed but no resolution):
Alternatives
Another option would be to update the capacitor-community/sqlite plugin to use OPFS instead of jeep-sqlite on the "web" platform.
Additional Information
My motivation for exploring alternatives to capacitor-community/sqlite is that I need access to the actual SQLite .db file, from JS (I haven't explored this much - so maybe it's possible). I've also seen some issues regarding performance issues ( capacitor-community/sqlite#602 ) that were concerning - and I assume using the more recent / official SQLite WASM build would be more future proof.