←back to thread

Sqlite3 WebAssembly

(sqlite.org)
506 points whatever3 | 5 comments | | HN request time: 0.832s | source
Show context
simonw ◴[] No.41851934[source]
Something that would be really fun would be to run SQLite in-memory in a browser but use the same tricks as Litestream and Cloudflare Durable Objects (https://simonwillison.net/2024/Oct/13/zero-latency-sqlite-st...) to stream a copy of the WAL log to a server (maybe over a WebSocket, though intermittent fetch() POST would work too).

Then on subsequent visits use that server-side data to rehydrate the client-side database.

From https://sqlite.org/forum/info/50a4bfdb294333eec1ba4749661934... is looks like WAL mode is excluded from the default SQLite WASM build so you would have to go custom with that.

replies(8): >>41852040 #>>41852194 #>>41853089 #>>41854540 #>>41854586 #>>41854654 #>>41855596 #>>41856415 #
dustinchilson ◴[] No.41852040[source]
Are you thinking something like https://electric-sql.com/
replies(1): >>41853301 #
1. PUSH_AX ◴[] No.41853301[source]
What’s the catch with this thing?
replies(1): >>41853915 #
2. T-Winsnes ◴[] No.41853915[source]
The security model is challenging, as it relies on Postgres users for iam. Your users essentially log directly into your db
replies(2): >>41854135 #>>41855021 #
3. dumbo-octopus ◴[] No.41854135[source]
Isn’t Postgres a fairly capable IAM provider, all things considered? I’d their access control mechanisms at least as much as a run of the mill external backend’s.
replies(1): >>41854423 #
4. T-Winsnes ◴[] No.41854423{3}[source]
For basic auth it works well, but the challenge comes when you need to integrate with oidc, need to enforce mfa, enable sso etc. session invalidation is also quite complicated.

You need an identity middle man in front of the Postgres identity to tackle these and validate that the session is still active. Last time I looked at electric it was a big challenge to integrate such a service. This might have improved since then however

5. infogulch ◴[] No.41855021[source]
You can see what this means specifically from the docs: https://electric-sql.com/docs/guides/auth