Running Postres inside a browser via WASM

published on 2022/10/04

Today we're open sourcing postgres-wasm with our friends at Snaplet.

postgres-wasm is a PostgreSQL server that runs inside a browser. It provides a full suite of features, including persisting state to browser, restoring from pg_dump, and logical replication from a remote database. Supabase

This is impressive.

They also list a couple of use cases for this

Some ideas we'll be playing with over the next few months:

  • Documentation: for tutorials and demos.
  • Offline data: running it in the browser for an offline cache, similar to sql.js or absurd-sql.
  • Offline data analysis: using it in a dashboard for offline data analysis and charts.
  • Testing: testing PostgresSQL functions, triggers, data modeling, logical replication, etc.
  • Dev environments: use it as a development environment — pull data from production or push new data, functions, triggers, views up to production.
  • Snapshots: create a test version of your database with sample data, then take a snapshot to send to other developers.
  • Support: send snapshots of your database to support personnel to demonstrate an issue you're having.