pglite

Embeddable Postgres with real-time, reactive bindings.

What is pglite?

Embeddable Postgres with real-time, reactive bindings.

Overview of pglite

What it is

PGlite is a WASM build of Postgres packaged into a TypeScript client library. It enables running Postgres in the browser, Node.js, Bun, and Deno without additional dependencies. The library is approximately 3 MB gzipped and supports extensions such as pgvector and PostGIS. Unlike earlier browser-based Postgres implementations, PGlite does not use a Linux virtual machine; it is Postgres compiled directly to WebAssembly.

Key features

  • Runs Postgres in browser, Node.js, Bun, and Deno with no extra dependencies.
  • Only about 3 MB gzipped in size.
  • Supports Postgres extensions including pgvector and PostGIS.
  • Can be used as an ephemeral in-memory database or persisted to the file system (Node/Bun/Deno) or indexedDB (browser).
  • Pure WASM implementation without a Linux VM.
  • Exposes a connection object compatible with pg (node-postgres) modules since version 0.5.13.

Use cases

Building reactive, realtime, local-first applications that run Postgres directly in the browser or in serverless environments. It can serve as an embedded database for Node.js, Bun, or Deno applications, and is suitable for testing, development, or offline-first scenarios where a full Postgres instance is impractical.

Getting started

Install the package:

npm install @electric-sql/pglite

Create an in-memory database and run a query:

import { PGlite } from "@electric-sql/pglite";

const db = new PGlite();
await db.query("select 'Hello world' as message;");
// -> { rows: [ { message: "Hello world" } ] }

For persistence, pass a path (Node/Bun/Deno) or an indexedDB URI (browser):

const db = new PGlite("./path/to/pgdata");   // filesystem
const db = new PGlite("idb://my-pgdata");    // browser indexedDB

License and pricing

Dual-licensed under Apache License 2.0 and PostgreSQL License. Open source.

Based on the project's public README and repository metadata.

Add this badge to your README

Featured on YunoDB Badge styles & help

Maintain this project? Show that it is featured on YunoDB.

Markdown[![Featured on YunoDB](https://yunodb.com/badge/electric-sqlpglite.svg)](https://yunodb.com/tools/electric-sqlpglite?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/electric-sqlpglite?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/electric-sqlpglite.svg" alt="Featured on YunoDB" height="20"></a>