Repolode
electric-sql

electric-sql/pglite

Embeddable WASM build of Postgres packaged as a TypeScript library, running in browsers, Node.js, Bun and Deno.

Stars
16,182
Forks
460
Open issues
161
Last commit
2 days ago

What is it?

PGlite packages a WebAssembly build of Postgres into a TypeScript client library, so you can run a real Postgres database inside a browser, Node.js, Bun or Deno process without installing a separate server. It can run as an in-memory database or persist data to the file system on Node, Bun and Deno, or to IndexedDB in the browser.

Unlike earlier "Postgres in the browser" projects, PGlite does not rely on a Linux virtual machine. It compiles PostgreSQL's single-user mode to WASM and adds an input/output layer so JavaScript can talk to it. The package is about 3 MB gzipped and supports a number of Postgres extensions, including pgvector and PostGIS.

PGlite is limited to a single user and connection, and the project is currently in alpha.

Key features

  • 01Runs Postgres in browsers, Node.js, Bun and Deno with no separate server
  • 02Supports in-memory mode and persistence to the file system or IndexedDB
  • 03Includes extensions such as pgvector and PostGIS
  • 04Packaged as a TypeScript library of roughly 3 MB gzipped
  • 05Installable via npm, Bun or Deno and loadable from a CDN

Use cases

  • Running Postgres-compatible tests without starting a database server
  • Building local-first web apps that store data in the browser
  • Prototyping SQL-backed features inside a Node or Deno script
  • Using vector search or spatial queries in a client-side app

Quick start

  1. 1

    Install the package into your Node.js project

    npm install @electric-sql/pglite
  2. 2

    Import PGlite and run a query on an in-memory database

Things to know

  • PGlite is single user and single connection.
  • The project is in alpha status, so expect possible breaking changes.

In collections

Topics

FAQ

What is pglite?
Embeddable WASM build of Postgres packaged as a TypeScript library, running in browsers, Node.js, Bun and Deno. PGlite packages a WebAssembly build of Postgres into a TypeScript client library, so you can run a real Postgres database inside a browser, Node.js, Bun or Deno process without installing a separate server. It can run as an in-memory database or persist data to the file system on Node, Bun and Deno, or to IndexedDB in the browser.
Is pglite free to use? What license does it have?
pglite is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is pglite still maintained?
Actively maintained. The last commit to pglite was on Oct 21, 2026.
What can I use pglite for?
Running Postgres-compatible tests without starting a database server Building local-first web apps that store data in the browser Prototyping SQL-backed features inside a Node or Deno script Using vector search or spatial queries in a client-side app
How do I install pglite?
Install the package into your Node.js project: npm install @electric-sql/pglite Import PGlite and run a query on an in-memory database
Where can I get pglite?
The source code and installation instructions are on GitHub: https://github.com/electric-sql/pglite

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects