---
title: "Postgres WASM by Snaplet and Supabase"
description: "postgres-wasm runs a full PostgreSQL 14 server in the browser by emulating an x86 machine with v86 rather than compiling Postgres to WASM directly."
url: "https://swe.quest/articles/postgres-wasm-by-snaplet-and-supabase-a942df855beab1df"
canonical: "https://supabase.com/blog/postgres-wasm"
source: "Supabase"
published: "2022-10-03"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 9
tags: ["postgres","webassembly","virtualization","browsers","networking"]
---

# Postgres WASM by Snaplet and Supabase

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2022-10-03, 9 min read, Deep dive. Original: [https://supabase.com/blog/postgres-wasm](https://supabase.com/blog/postgres-wasm)

## Summary

postgres-wasm runs a full PostgreSQL 14 server in the browser by emulating an x86 machine with v86 rather than compiling Postgres to WASM directly. It boots a minimal Buildroot Linux image and lazily loads the rest over a 9P filesystem via HTTPS, and it uses the page\_poison=on kernel parameter so freed memory compresses well, which brings the snapshot of a running Postgres down to about 12MB. Networking goes through a forked websockproxy that converts raw ethernet frames into TCP, with an nginx reverse proxy that maps private IPs to ports so external clients like psql, PgAdmin or a logical replication peer can connect. Other hurdles included a v86 JIT bug that caused PG14 segfaults, worked around by switching Postgres to sysv shared memory, and an inbox-folder listener for running scripts inside the VM.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [WebAssembly](https://swe.quest/tags/webassembly.md) (Languages)
- [Virtualization](https://swe.quest/tags/virtualization.md) (Infrastructure)
- [Browsers](https://swe.quest/tags/browsers.md) (Web & mobile)
- [Networking](https://swe.quest/tags/networking.md) (Infrastructure)

## Prerequisites

- PostgreSQL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- Linux boot and kernel parameters ([easy posts on Linux](https://swe.quest/tags/linux.md?difficulty=easy))
- WebSockets ([easy posts on Real-time systems](https://swe.quest/tags/realtime.md?difficulty=easy))

## Keywords

postgres-wasm, v86, Buildroot, 9P, websockproxy, Snaplet, Supabase

## Related posts

- [Live Share: Connect to in-browser PGlite with any Postgres client](https://swe.quest/articles/live-share-connect-to-in-browser-pglite-with-any-postgres-client-bc4a637942fe2ca5.md): Supabase · 2024-10-10 · Medium · 6 min read · PostgreSQL, Networking, Load balancing, WebAssembly, Browsers
  database.build (formerly postgres.new) adds Live Share, which exposes an in-browser PGlite (WASM Postgres) database via a unique connection string usable from psql, pg\_dump, ORMs or IDEs.
- [Edge-compatible Serverless Driver for Postgres](https://swe.quest/articles/edge-compatible-serverless-driver-for-postgres-9b0d09c6c7a067d0.md): Neon · 2022-12-08 · Medium · 9 min read · PostgreSQL, Serverless, Networking, Cryptography, WebAssembly
  Neon's @neondatabase/serverless driver lets V8-isolate platforms like Cloudflare Workers, which lack TCP, speak the real Postgres wire protocol by tunnelling it over a WebSocket to an open-source Go proxy that relays to TCP.
- [Postgres Foreign Data Wrappers with Wasm](https://swe.quest/articles/postgres-foreign-data-wrappers-with-wasm-121e854eab291417.md): Supabase · 2024-08-16 · Medium · 5 min read · PostgreSQL, WebAssembly, Rust, Sandboxing & isolation
  Supabase Wrappers, a Rust framework for building Postgres Foreign Data Wrappers, now supports WebAssembly FDWs that are downloaded from URLs like GitHub or S3, checksum-verified, cached and run in a sandboxed Wasm runtime inside the Postgres extension.
- [Supabase is now on Postgres 13.3](https://swe.quest/articles/supabase-is-now-on-postgres-13-3-2931acd8ef3ece75.md): Supabase · 2021-07-26 · Easy · 3 min read · PostgreSQL, Performance engineering
  New Supabase projects now run Postgres 13.3 (up from 12.0), bringing native gen\_random\_uuid, parallel index vacuuming, incremental sorting and smaller B-tree indexes.
- [How We Built the Turso Shell in the Browser](https://swe.quest/articles/how-we-built-the-turso-shell-in-the-browser-3b4c7642ce66be0b.md): Turso · 2025-10-14 · Medium · 9 min read · WebAssembly, SQLite, React, Frontend, Browsers
  Turso's SQLite-compatible database can run entirely in the browser via WebAssembly, persisting data to OPFS with no backend.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
