op-sqlite icon indicating copy to clipboard operation
op-sqlite copied to clipboard

[Request]: Web support with wasm

Open abretonc7s opened this issue 8 months ago • 4 comments

What do you need?

Have you considered web support ? It would be amazing for cross platform apps!

abretonc7s avatar May 21 '25 07:05 abretonc7s

Answer is same as always. There are efforts of running sqlite on the browser. But the biggest problem is persistance, but TL:DR: it doesn't really work and adds a lot of complexity, providing this for free is not really sustainable.

ospfranco avatar May 21 '25 07:05 ospfranco

Thanks for the quick reply!

In my apps, I’ve built cross-platform offline-first support with web compatibility using expo SQLite, but hit the OPFS single-tab limitation. I fixed this with a SharedWorker and master/slave architecture, similar to Notion’s approach (details here: notion wasm sqllite I can share more on my setup if you’re interested...

I’m exploring op-sqlite as a replacement, but web support is key. If you added expo-sqlite-like web compatibility, op-sqlite could directly leverage this model for a best-of-both-worlds solution. Thoughts?

abretonc7s avatar May 22 '25 03:05 abretonc7s

Oh, I didn't know expo added support for web. It's definitely interesting, but I don't like expo only setups and I'm not familiar with the entire react-native-web compilation chain, so... PRs are welcome :)

ospfranco avatar May 22 '25 06:05 ospfranco

I started playing around with this

Image

I just added react-native-web to the sample app, and for now I'm just trying to load sqlite via @sqlite.org/sqlite-wasm. I got as far as having a SharedWorker load "correctly", however, it seems OPFS is not working. @abretonc7s if you understand webpack better maybe you can give a hand and see what is wrong.

I still have no idea how this entire thing is supposed to work as a packaged library. But if sqlite can be loaded worse case, I can just add a lot of instructions to modify the webpack config and op-sqlite can just be a API on top for web.

ospfranco avatar May 23 '25 11:05 ospfranco