PGlite
activeby ElectricSQL · since 2024 · also known as PGlite by Electric
Real PostgreSQL compiled to WebAssembly: an embeddable Postgres for browsers, Node, Bun and Deno.
Overview
PGlite is a WASM build of PostgreSQL packaged as a TypeScript library by ElectricSQL. Rather than emulating Postgres or running a Linux VM, it compiles Postgres' single-user mode to WebAssembly and wraps it with a JS API, so you get genuine Postgres SQL, types and many extensions (pgvector, PostGIS, pg_trgm and more) in about 3 MB gzipped. Data can live in memory, IndexedDB, OPFS or the filesystem, and it integrates with Electric's sync engine for local-first apps. It has become a popular choice for in-browser demos, tests and dev databases, but it is single-connection and not a replacement for a Postgres server.
Strengths & trade-offs
Strengths
- +Genuine PostgreSQL semantics in the browser and JS runtimes
- +Small download (about 3 MB gzipped) with no native dependencies
- +Loads Postgres extensions such as pgvector and PostGIS
- +Persists to IndexedDB, OPFS or the filesystem
- +Fast, disposable Postgres instances for tests and CI
Trade-offs
- −Single-user mode: one connection at a time
- −Pre-1.0 API that still changes between releases
- −Performance below native Postgres, especially for large data
- −Extension support limited to those ported to WASM
Great for
- +Local-first web apps with Electric sync
- +In-browser SQL playgrounds and tutorials
- +Ephemeral Postgres for unit tests in Node/Bun
- +Client-side vector search with pgvector
Think twice for
- −Multi-user production servers
- −Large datasets or heavy concurrency
- −Non-JavaScript environments
Capabilities
Native or official first-party support · 15 of 25 tracked
Scale & consistency
- Comfortable data size
- Small · ≤ 100 GB
- Horizontal scaling
- None
- Multi-region
- No
- Transactions
- Full ACID
- Consistency
- Strong
- Schema
- Strict
- Architecture
- Embedded, In memory
- Query languages
- SQL, PL/pgSQL
Single connection, single process; best for local datasets up to a few GB.
Deployment
Ecosystem
Alternatives to PGlite
The in-process SQL engine that ships in every phone, browser and OS: one file, zero servers.
pglite vs sqlite →In-process columnar SQL database: the SQLite of analytics, running inside your app or notebook.
pglite vs duckdb →The extensible, standards-first open-source relational database.
pglite vs postgresql →Read-path sync engine that streams partial replicas of Postgres to clients over plain HTTP.
pglite vs electricsql →Turso's open-contribution SQLite fork with native vectors, a network server and embedded replicas.
pglite vs libsql →Ground-up Rust rewrite of SQLite with concurrent writes, async I/O, CDC and vector search.
pglite vs turso-database →PGlite FAQ
What is PGlite?
PGlite is a relational database by ElectricSQL, first released in 2024. PGlite is a WASM build of PostgreSQL packaged as a TypeScript library by ElectricSQL. Rather than emulating Postgres or running a Linux VM, it compiles Postgres' single-user mode to WebAssembly and wraps it with a JS API, so you get genuine Postgres SQL, types and many extensions (pgvector, PostGIS, pg_trgm and more) in about 3 MB gzipped. Data can live in memory, IndexedDB, OPFS or the filesystem, and it integrates with Electric's sync engine for local-first apps. It has become a popular choice for in-browser demos, tests and dev databases, but it is single-connection and not a replacement for a Postgres server.
Is PGlite open source?
Yes. PGlite is open source. License: Apache License 2.0 / PostgreSQL License.
Does PGlite support ACID transactions?
Yes. PGlite supports full ACID transactions, with strong consistency.
Does PGlite scale horizontally?
PGlite does not scale horizontally; it runs on a single node, so you scale it up rather than out. It is comfortable at small scale (≤ 100 GB).
How can I run PGlite?
You can self-host it, embed it in your application and run it at the edge.
What is PGlite best for?
PGlite is a strong fit for local-first web apps with Electric sync; in-browser SQL playgrounds and tutorials; and ephemeral Postgres for unit tests in Node/Bun. Think twice for multi-user production servers.
What are the best alternatives to PGlite?
Common alternatives to PGlite include SQLite, DuckDB, PostgreSQL, ElectricSQL and libSQL. The right choice depends on your workload, scale and hosting; WhichDB's smart match ranks them against your requirements.
How popular is PGlite?
PGlite ranks #57 of 844 databases on the WhichDB Score (35.1/100), and #17 among relational databases. The score combines public adoption signals such as package downloads, GitHub activity, job posts and developer discussion.