Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
postgres-browser
Discontinued A PostgresQL server running in your browser [Moved to: https://github.com/snaplet/postgres-wasm]
-
copycat
Generate deterministic fake values: The same input will always generate the same fake-output. (by snaplet)
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Today we're open sourcing postgres-wasm with our friends at Snaplet.
Offline data: running it in the browser for an offline cache, similar to sql.js or absurd-sql.
See source code.
For now, this is very experimental - but it has a lot of potential. If you want to get involved, please reach out to us or the team at [Snaplet(https://www.snaplet.dev/). The work they're doing over at Snaplet is incredible, and we've had a blast collaborating with them.
Next, we need to run the the VM inside our browser. How? WASM. We use v86 to run our VM inside the browser. Our demo application is very simple - plain HTML and some basic styling.
Running Postgres in a browser is great, but connecting to it with PgAdmin is even better. Unfortunately browsers block TCP network access to the VM. To circumvent this, we proxy the traffic through websockets. We run a fork of Websockproxy which allows the emulator to talk to the internet by converting data sent over a websocket port into TCP packets. Our fork of Websockproxy adds the ability to tunnel into the Postgres server.
We achieve this by mounting a compressed 9P filesystem in the VM. 9P provides a Python script which takes a filesystem folder,renames every file an 8-character name and produces a filesystem.json file representing a nested structure with files, original file names, sizes, etc.