pglite
Embeddable Postgres with real-time, reactive bindings.
PGlite is a 3 MB WebAssembly build of Postgres that runs in the browser, Node, Bun, or Deno with no server, supporting in-memory or persisted storage and extensions like pgvector.
PGlite is a version of PostgreSQL — one of the world's most popular relational databases (a structured way to store and query data) — compiled to run entirely inside a web browser or JavaScript runtime, with no server required. It uses WebAssembly (WASM), a technology that lets languages like C be compiled and run directly in browsers or JavaScript environments.
The package weighs only 3 MB compressed and can be installed via npm like any other JavaScript library. Once imported, you can run SQL queries directly in your app — no installation, no server to manage. You can run it as a temporary in-memory database (data disappears when you close the tab) or with persistence: in the browser it saves data to indexedDB (a built-in browser storage system), and in Node.js, Bun, or Deno it saves to the local filesystem. It also supports Postgres extensions including pgvector (used for AI similarity searches).
PostgreSQL normally works by forking a new operating system process for each connection, but WebAssembly does not support forking processes. PGlite works around this by using PostgreSQL's single-user mode — a minimal operating mode normally used for bootstrapping — and adding a custom input/output pathway for JavaScript interaction. As a result, PGlite only supports one connection at a time. It is dual-licensed under Apache 2.0 and the PostgreSQL License and is built by ElectricSQL.
Where it fits
- Embed a real Postgres database directly inside a web app with no server.
- Build a local-first or offline-capable app that syncs later.
- Run pgvector similarity searches client-side for an in-browser AI feature.
- Use Postgres in a Node, Bun, or Deno script without installing a database.