explaingit

electric-sql/pglite

Analysis updated 2026-06-24

15,208TypeScriptAudience · developerComplexity · 3/5LicenseSetup · easy

TLDR

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.

Mindmap

mindmap
  root((pglite))
    Inputs
      SQL queries
      JS API calls
    Outputs
      Query results
      Persisted data
    Use Cases
      Local-first web app
      Offline browser DB
      Edge runtime store
      pgvector search
    Tech Stack
      TypeScript
      WebAssembly
      Postgres
      IndexedDB
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Embed a real Postgres database directly inside a web app with no server.

USE CASE 2

Build a local-first or offline-capable app that syncs later.

USE CASE 3

Run pgvector similarity searches client-side for an in-browser AI feature.

USE CASE 4

Use Postgres in a Node, Bun, or Deno script without installing a database.

What is it built with?

TypeScriptWebAssemblyPostgresNode.jsIndexedDB

How does it compare?

electric-sql/pglitefeathersjs/feathersdifferent-ai/openwork
Stars15,20815,25315,157
LanguageTypeScriptTypeScriptTypeScript
Last pushed2026-05-22
MaintenanceMaintained
Setup difficultyeasymoderatemoderate
Complexity3/53/53/5
Audiencedeveloperdevelopervibe coder

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

npm install and import, only one connection at a time because the underlying Postgres runs in single-user mode.

Dual-licensed under Apache 2.0 and the PostgreSQL License: use, modify, and ship it including commercially as long as you keep the notices.

In plain English

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.

Copy-paste prompts

Prompt 1
Show me how to install pglite via npm and run my first SQL query inside a React app.
Prompt 2
Write a code sample that persists pglite data to IndexedDB in the browser and reloads it after refresh.
Prompt 3
Use pglite with pgvector to build an in-browser semantic search over a list of documents.
Prompt 4
Compare pglite to better-sqlite3 and IndexedDB for a local-first web app.
Prompt 5
Help me set up pglite in a Node.js script that saves its database to a file on disk.

Frequently asked questions

What is pglite?

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.

What language is pglite written in?

Mainly TypeScript. The stack also includes TypeScript, WebAssembly, Postgres.

What license does pglite use?

Dual-licensed under Apache 2.0 and the PostgreSQL License: use, modify, and ship it including commercially as long as you keep the notices.

How hard is pglite to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is pglite for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub electric-sql on gitmyhub

Verify against the repo before relying on details.