Lurker News
Hey, Sam and the team from ElectricSQL here.

PGlite is a WASM Postgres build packaged into a TypeScript/JavaScript client library, that enables you to run Postgres in the browser, Node.js and Bun, with no need to install any other dependencies. It's 3mb Gzipped, now has support for many Postgres extensions, including pgvector, and it has a reactive "live query" API. It's also fast, with CRUD style queries executing in under 0.3 ms, and larger, multi-row select queries occurring within a fraction of a single frame.
PGlite started as an experimental project we shared on X, and the response to it was incredible, encouraging us to see how far we could take it. Since then we have been working to get it to a point where people can use it to build real things. We are incredibly excited as today, with the release of v0.2, the Supabase team has released the amazing http://postgres.new site built on top of it. Working with them to deliver both PGlite and postgres.new has been a joy.
- https://pglite.dev - PGlite website
- https://github.com/electric-sql/pglite - GitHub repo
- https://pglite.dev/docs - Docs on how to use PGlite
- https://pglite.dev/extensions - Extensions catalog
- https://pglite.dev/benchmarks - Early micro-benchmarks
- https://pglite.dev/repl - An online REPL so that you can try it in the browser
We would love you to try it out, and we will be around to answer any questions.

Comments (108) 37 threads

Earlier comments
isoprophlex3 replies#
That's great! Corpo beancounters want us to move off docker on EC2 onto bare metal, making both dev and deploy experience terrible. This will help ease pain!
samstave2 replies#
Weird question: Since you mention 'bare-metal' and this is "enables you to run Postgres in the browser"

UH, could you do:
bare_metal --> HeadlessGPU-Chrome --> PGLite with whatever orchesrtration and you have a an automatable 'browser' that can scrape/store/logic/log/be-config'd from/lookup directly to your browserDB
and maybe run a fastAPI ontop of such that you have a full stack, baremetal, headless, browserDB/fastAPI/endpoint processing doohicky?
Or does this sound dumb?
Because this is exactly what I actually need and am attempting to create - but its beyond my capabilities in any functional/elegant implementation...
https://www.browserless.io/blog/browserless-gpu-instances
https://github.com/dhamaniasad/HeadlessBrowsers

samwillis1 reply#
PGlite also runs in Node and Bun, so you can easily run it on backend servers. (couldn't fit that in the HN headline)
samstave1 reply#
Sorry if this is in the RTFM;

So, you can basically use this to deploy a portable fully enclosed little webapp.
Basically any little web-app that has a bunch of backend DB:
A sales USB drive that loads a page that then has the pglite of all your product stuff on there. and you can just provide custom buttons to slurp data either way.
Utils to yank a [data] from a postgress server, onto your little sneaker-DB-USB -- then carry it over and to a DB function...
A little util USB that you already have it setup such that you can curl a bunch of data directly into tables on your little headless-browser-pglite minion?
Full Kisok DB USB (SSD) upgrades.
Basically - running a pico headless postgress DB with a webUI?
--- aside:
samwillis March 2008
samstave March 2009
:-)
---
WOW:
https://i.imgur.com/6YLwEuj.png
--
Yeah this is pretty dopes.

Continue this thread — 1 reply

isoprophlex#
It doesn't need so many moving parts imo. I was thinking to just grab the npm package and slap a tiny TS interface on top of that to mock my bespoke vector db. In the vein of https://news.ycombinator.com/item?id=41225080
cheema33#
> Corpo beancounters want us to move off docker on EC2 onto bare metal

There is a very good reason for it. EC2 is way way overpriced.

postalrat#
And you can't have your own docker on bare metal?
loevborg1 reply#
PGLite is amazing for integration testing of queries against a real in-memory db.

Is it possible to use PGLite for that purpose in non-JS environments, like e.g. golang?

samwillis1 reply#
You can use pg-gateway from supabase (https://github.com/supabase-community/pg-gateway) to start a PGlite and connect form any standard PG client.

Support for other languages is high on my list, the plan is to build a "libpglite" as a native C lib and a WASI build that can run in any WASM runtime.

loevborg#
Thanks!

From my perspective, being able to pull pglite into the same golang process is preferable - faster, less IPC complexity, no risk of leaving lingering state.
Making postgres an in-process dependency is much of the appeal of pglite for me.

Kinrany1 reply#
Can it run in Node while still persisting data to disk?

Load more comments