档案库 · 开发与企业工具 · 产品决策 · 2024–2026
ElectricSQL 的 PGlite 押注浏览器中的 Postgres:WASM 构建,1500 万次下载
一个 3MB 的 WASM Postgres,可在浏览器、Node 和 Bun 中运行——支持 pgvector 和实时查询——从 X 上的实验变成了 Supabase 的 postgres.new 基础。
ElectricSQL
做的是什么生意
ElectricSQL, the startup behind reactive sync tooling around Postgres, builds PGlite: a WASM build of Postgres packaged as a TypeScript/JavaScript client library that runs full Postgres in the browser, Node, Bun and Deno, with live queries, live sync, and extensions including pgvector and PostGIS.
起因
Sam and the team at ElectricSQL, a startup building reactive, realtime, local-first tooling around Postgres, shared an experimental WASM Postgres build on X. The response was extraordinary, encouraging them to see how far they could take it and to push the experiment to a point where people could use it to build real things.
经过
On 2024-08-12 they released v0.2 — extension loading including pgvector, a reactive live-query API, about 3MB gzipped — and the same day the Supabase team launched postgres.new, an in-browser Postgres playground built on PGlite. The Show HN drew 509 points and 108 comments: developers described it as filling the gap where only Dockerized Postgres had sat for test suites and in-process embedding, while skeptics probed maturity and noted the single-user limitation.
还没有结局,它还在跑。
背景
PGlite 是 PostgreSQL 的 WASM 构建,打包成 TypeScript/JavaScript 客户端库,由 ElectricSQL 开发——这家初创公司围绕 Postgres 构建响应式、实时、本地优先的数据工具。它让开发人员可以在浏览器、Node、Bun 或 Deno 中运行完整的 Postgres 数据库,无需其他依赖:压缩后约 3MB,支持 pgvector 和 PostGIS 的扩展加载,持久化到文件系统或 IndexedDB,并提供响应式实时查询 API。
背后的赌注是,构建浏览器内和本地优先应用的开发人员会选择真正的 Postgres——凭借其扩展、方言和同步能力——而不是满足于 SQLite 替代品或强制使用远程数据库。PGlite 最初是一个实验项目,团队在 X 上分享;反响非同寻常,足以让 ElectricSQL 继续推动其走向生产应用,解决了尽管 Postgres 的进程分叉模型但编译为 WASM 的难题,方法基于 Postgres 的单用户模式。
2024-08-12,v0.2 发布了 pgvector 和实时查询支持,同一天 Supabase 推出了 postgres.new,一个基于 PGlite 的浏览器内 Postgres 游乐场。Show HN 获得了 509 分,108 条评论——开发者称其填补了只有 Docker 化 Postgres 才能满足的空白——而批评者则测试其极限并指出了单用户限制。截至 2026-09-05 快照,pglite.dev 显示 15.9k GitHub 星标和 15.2M npm 下载量,该包仍活跃发布。
这件事要成立,得有什么
- 嵌入真正的 Postgres 消除了 SQLite 妥协:团队可以在测试和进程内使用与生产环境相同的方言、扩展和查询。
- 这个棘手的工程问题——Postgres 分叉进程,而 WASM 无法做到——通过重用 Postgres 的单用户模式得以解决,将“不可能”变成了 3MB 的库。
- 开源使采用成为营销:另一家独立公司 Supabase 在 v0.2 发布当天就在 PGlite 上推出了 postgres.new,为 ElectricSQL 带来了原本无法获得的传播效果。
- 响应式实时查询和同步指向了超越玩具的用途:产品页面将 PGlite 定位为“具有响应性和实时同步”的可嵌入 Postgres,正是本地优先应用所需的层。
可借鉴之处
先证明不可能的部分:通过将可嵌入的 3MB WASM Postgres 开源,ElectricSQL 将“浏览器中的 Postgres”从一个说法变成了开发者可以采用的工件。
后续进展
截至 2026-09-05,PGlite 已上线并作为开源库被广泛采用。pglite.dev 快照显示 electric-sql/pglite 有 15.9k GitHub 星标,@electric-sql/pglite 的 npm 下载量为 15.2M;npm 包版本为 0.5.8,描述为“来自 Electric 的 Postgres WASM 构建”,用于构建响应式、实时、本地优先的应用,采用 Apache-2.0 和 PostgreSQL 许可证双重许可。ElectricSQL 自身的融资或收入在所审查的来源中未有记录;本条目记录了产品押注及其采用情况。
资料来源
发现哪里写错了?告诉我们。
轮到你了
你刚读完一家。说说你在做什么,看看谁在赌同一件事。
免费账号 · 3 次免费提问 · 不用绑卡