TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: PGlite – in-browser WASM Postgres with pgvector and live sync

509 点作者 samwillis9 个月前
Hey, Sam and the team from ElectricSQL here.<p>PGlite is a WASM Postgres build packaged into a TypeScript&#x2F;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&#x27;s 3mb Gzipped, now has support for many Postgres extensions, including pgvector, and it has a reactive &quot;live query&quot; API. It&#x27;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.<p>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 <a href="http:&#x2F;&#x2F;postgres.new" rel="nofollow">http:&#x2F;&#x2F;postgres.new</a> site built on top of it. Working with them to deliver both PGlite and postgres.new has been a joy.<p>- <a href="https:&#x2F;&#x2F;pglite.dev" rel="nofollow">https:&#x2F;&#x2F;pglite.dev</a> - PGlite website<p>- <a href="https:&#x2F;&#x2F;github.com&#x2F;electric-sql&#x2F;pglite">https:&#x2F;&#x2F;github.com&#x2F;electric-sql&#x2F;pglite</a> - GitHub repo<p>- <a href="https:&#x2F;&#x2F;pglite.dev&#x2F;docs" rel="nofollow">https:&#x2F;&#x2F;pglite.dev&#x2F;docs</a> - Docs on how to use PGlite<p>- <a href="https:&#x2F;&#x2F;pglite.dev&#x2F;extensions" rel="nofollow">https:&#x2F;&#x2F;pglite.dev&#x2F;extensions</a> - Extensions catalog<p>- <a href="https:&#x2F;&#x2F;pglite.dev&#x2F;benchmarks" rel="nofollow">https:&#x2F;&#x2F;pglite.dev&#x2F;benchmarks</a> - Early micro-benchmarks<p>- <a href="https:&#x2F;&#x2F;pglite.dev&#x2F;repl" rel="nofollow">https:&#x2F;&#x2F;pglite.dev&#x2F;repl</a> - An online REPL so that you can try it in the browser<p>We would love you to try it out, and we will be around to answer any questions.

36 条评论

simonw9 个月前
I&#x27;d seen this running in a browser before (the ~3MB download is really impressive for that), but I hadn&#x27;t clocked that it runs server-side with Node.js and Bun as well: <a href="https:&#x2F;&#x2F;pglite.dev&#x2F;docs&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pglite.dev&#x2F;docs&#x2F;</a><p>Since that&#x27;s still not spinning up an actual network server, that feels like it&#x27;s an alternative to SQLite - you can spin up a full in-process PostgreSQL implementation, that persists to disk, as part of an existing Node.js&#x2F;Bun application.<p>That&#x27;s really interesting!<p>I&#x27;d love to use this from Python, via something like <a href="https:&#x2F;&#x2F;github.com&#x2F;wasmerio&#x2F;wasmer-python">https:&#x2F;&#x2F;github.com&#x2F;wasmerio&#x2F;wasmer-python</a> or <a href="https:&#x2F;&#x2F;github.com&#x2F;bytecodealliance&#x2F;wasmtime-py">https:&#x2F;&#x2F;github.com&#x2F;bytecodealliance&#x2F;wasmtime-py</a> - has anyone run PGlite via one of those wrappers yet?
评论 #41225520 未加载
评论 #41226800 未加载
评论 #41228367 未加载
评论 #41226494 未加载
评论 #41242461 未加载
creativedg9 个月前
Huge fan of PGlite.<p>It&#x27;s the perfect solution to have Postgres without the need of Docker. With just `npm install`, you can have a Postgres instance on your computer. So, it&#x27;s extremely easy to onboard a new developer in your team.<p>And, the good news, PGlite works perfectly with Next.js.<p>I&#x27;m using PGlite in local and development environment with Next.js Boilerplate: <a href="https:&#x2F;&#x2F;github.com&#x2F;ixartz&#x2F;Next-js-Boilerplate">https:&#x2F;&#x2F;github.com&#x2F;ixartz&#x2F;Next-js-Boilerplate</a><p>With only one command `npm install`, you can have a full-stack application, which also includes the database (a working Postgres). And, no need to have&#x2F;install external tools.
评论 #41226518 未加载
sgbeal9 个月前
To keep the next person from having to look (or ask without looking): it supports browser-side persistence via IndexedDB and OPFS: &lt;<a href="https:&#x2F;&#x2F;pglite.dev&#x2F;docs&#x2F;filesystems" rel="nofollow">https:&#x2F;&#x2F;pglite.dev&#x2F;docs&#x2F;filesystems</a>&gt;
评论 #41225028 未加载
Cu3PO429 个月前
When I saw the headline, I immediately thought &quot;I bet this would go really well with ElectricSQL&quot;, so it&#x27;s great to see this coming from you!<p>The immediate DX is incredible and I&#x27;m itching to use PGLite (and ElectricSQL) in a production project, I expect it would remove quite a few pain points I&#x27;m currently experiencing. (Also, I just like working with CRDTs.)<p>I don&#x27;t have any constructive criticism to offer right this moment, but I just wanted to congratulate you on the launch and an incredible looking product!
satvikpendem9 个月前
Congrats on the Show HN. I follow the ElectricSQL Discord server and I was distinctly interested in this but for other languages than TypeScript, so it&#x27;s nice to see that making it language independent is high on your list. I also saw that ElectricSQL is being rewritten due to architectural changes, does that impact PGlite at all or are they separate projects now? What is the relationship between PGlite and ElectricSQL as well, just curious?<p>Also, fun etymological thing, SQLite is actually SQL-ite, as in, urbanite, not SQ-Lite, but due to rebracketing [0] and libfixing [1], now people seem to use the -lite suffix rather than the -ite one, presumably because <i>lite</i> actually implies something whereas <i>ite</i> would not, as much. It&#x27;s like how helicopter is actually <i>helic</i> and <i>opter</i>, a helical wing that spins, but now people think of it as <i>heli</i> and <i>copter</i>, calling other things related to it like helipad, or quadcopter, as Wikipedia states.<p>[0] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Rebracketing" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Rebracketing</a><p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Libfix" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Libfix</a>
评论 #41226698 未加载
Retr0id9 个月前
Normally I&#x27;d say the main difference between postgres and SQLite is that the latter is in-process. Now that they can <i>both</i> be in-process, is there a more detailed comparison of the two? When might I prefer one over the other?
评论 #41235191 未加载
评论 #41231637 未加载
评论 #41226514 未加载
bezbac9 个月前
I recently experimented with using pglite for API integration tests in one of my side projects. It worked pretty well and has much better DX than using something like testcontainers[0] to spin up postgres running in docker.<p>[0]: <a href="https:&#x2F;&#x2F;testcontainers.com" rel="nofollow">https:&#x2F;&#x2F;testcontainers.com</a>
评论 #41226107 未加载
评论 #41225840 未加载
bearjaws9 个月前
PGlite &#x2F; ElectricSQL is definitely something I want to use in a future job.<p>The ability to replicate and subscribe to the changes, all within the browser seems incredibly powerful.<p>Having worked on medical software that runs a 2,000,000+ patient workload that perform refills for chemotherapy&#x2F;HIV&#x2F;immuno drugs, where it was common for people to trample each others work as they ran insurance, called patients etc...<p>We had to roll our own locking system that relied on interval functions (yay IE7) and websockets... This meant when you called the patient, someone running financial assistance would be unable to work on the same profile.<p>I can envision other uses for FTS or even vector search locally, since they are insanely expensive at scale.
评论 #41227387 未加载
saurik9 个月前
Does there happen to be a native analog to this? So like, if I eventually want some kind of native app, I wouldn&#x27;t have to throw away the architecture entirely and start over? I only see mention of the WASM version of this in the website&#x2F;docs.
评论 #41225185 未加载
ZitchDog9 个月前
&gt; it has a reactive &quot;live query&quot; API<p>Very cool! Most of the examples for reactive queries are very basic (only single tables). Do live queries support joins &#x2F; aggregations?
评论 #41227584 未加载
herpdyderp9 个月前
What&#x27;s the equivalent Postgres version? Meaning, if I wanted to make sure my app that is currently using a Postgres Docker image is compatible with PGlite before switching, which version of Postgres should my Docker image be on?<p>I see &quot;PostgreSQL 15devel&quot; in a screenshot so I&#x27;m assuming that means v15 but explicit documentation on current and future Postgres version usage would be very nice. For example, how will I know when (if) you update to v16?
评论 #41227138 未加载
metadat9 个月前
How did they manage to fit Postgres in 3MB?
评论 #41226009 未加载
cpursley9 个月前
Woah, this is neat - insane that it can handle extensions.<p>Just added a new section to my &quot;Postgres Is Enough&quot; gist:<p><a href="https:&#x2F;&#x2F;gist.github.com&#x2F;cpursley&#x2F;c8fb81fe8a7e5df038158bdfe0f06dbb#in-browser--wasm" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;cpursley&#x2F;c8fb81fe8a7e5df038158bdfe0f...</a>
FlyingSnake9 个月前
PGLite is a wonderful achievement and I&#x27;ve a fan of it since it&#x27;s early days.<p>If they get it to a stage where other languages apart from JS can use it, it could be revolutionary. The possibilities are limitless.
AlexErrant9 个月前
Bug report? On <a href="https:&#x2F;&#x2F;pglite.dev&#x2F;repl&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pglite.dev&#x2F;repl&#x2F;</a> running `SELECT &#x27;a fat cat sat on a mat and ate a fat rat&#x27;::tsvector @@ &#x27;cat &amp; rat&#x27;::tsquery;` works, which is cool.<p>However, running `SELECT to_tsvector(&#x27;fat cats ate fat rats&#x27;) @@ to_tsquery(&#x27;fat &amp; rat&#x27;);` fails with `y is not a function`. Then trying to run the first query yields `null`, which is weird. I can open an issue if you want :)
评论 #41225813 未加载
NetOpWibby9 个月前
This is exciting. My database of choice is EdgeDB, which uses Postgres under the hood. It&#x27;s not so far-fetched to imagine EdgeDB in the browser now!
cheema339 个月前
The filesystems page at <a href="https:&#x2F;&#x2F;pglite.dev&#x2F;docs&#x2F;filesystems" rel="nofollow">https:&#x2F;&#x2F;pglite.dev&#x2F;docs&#x2F;filesystems</a> says the following:<p>&gt; &quot;We would recommend using the IndexedDB VFS in the browser at the current time as the OPFS VFS is not supported by Safari.&quot;<p>Is it possible to configure PGLite to use IndexedDB on Safari and OPFS on Chrome &amp; Firefox?
评论 #41232355 未加载
drzaiusx119 个月前
Anyone know if something similar is available for MySQL&#x2F;Maria? This is very cool, especially given the tiny size of it
srameshc9 个月前
If I understand correctly, this is like SQLite, but Postgres. I love SQLite, but sometimes I need a little more. So, no more saving Date as text and we have arrays, jsonb etc and all the good stuff from Postgres. Am I right ?
评论 #41226016 未加载
评论 #41233686 未加载
ChrisArchitect9 个月前
Related:<p>Subabase announcement post<p><i>Postgres.new: In-browser Postgres with an AI interface</i><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=41224286">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=41224286</a>
blueprint9 个月前
Anyone know how this would play with at-rest encryption extensions?
评论 #41226820 未加载
ggregoire9 个月前
I was gonna ask what do people use to sync their local pg with their remote pg, but turns out, that&#x27;s exactly what the authors are building. Cool stuff, and gratz on pglite!
wejick9 个月前
Curious to know How &quot;vanilla&quot; the pglite compared to the vanilla postgres? I saw many people are using this for automated testing and dev environment.
batmansmk9 个月前
Pretty awesome. Would love to use it in CI and locally for our PG product. We use Prisma, so I guess we have to wait for the connector that looks like pg to plug it in.
评论 #41225386 未加载
评论 #41226243 未加载
评论 #41225356 未加载
isoprophlex9 个月前
That&#x27;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!
评论 #41226425 未加载
评论 #41227965 未加载
评论 #41228296 未加载
loevborg9 个月前
PGLite is amazing for integration testing of queries against a real in-memory db.<p>Is it possible to use PGLite for that purpose in non-JS environments, like e.g. golang?
评论 #41226268 未加载
Kinrany9 个月前
Can it run in Node while still persisting data to disk?
评论 #41226312 未加载
vivzkestrel9 个月前
How does it compare with <a href="https:&#x2F;&#x2F;postgres.new&#x2F;" rel="nofollow">https:&#x2F;&#x2F;postgres.new&#x2F;</a>
评论 #41235848 未加载
sam_perez9 个月前
Oh cool, how would you compare this to DuckDB?
makkesk89 个月前
Awesome work! A killer feature of sqlite that I would love to see in pglite would be javascript window functions.
评论 #41226159 未加载
sabr9 个月前
This is amazing! Will there be something like Litestream&#x2F;rqlite for PGlite?
revskill9 个月前
The migration docs to integrate with Vite&#x2F;webpack is still lacking though.
namanyayg9 个月前
How does the performance compare to actual postgres?
评论 #41226152 未加载
teaearlgraycold9 个月前
Heads up, the supabase link on the front page 404s
评论 #41226272 未加载
non-9 个月前
Would really like to see a benchmarking analysis vs SQLite. How do they compare on memory usage and overhead?<p>I already default to SQLite for new side projects with the idea that &quot;eventually I&#x27;ll migrate to Postgres if this project gets legs&quot;, so switching to PGlite feels like a no-brainer as long as it&#x27;s not going to weigh my apps down or force me to upgrade out of whatever entry-level server solution I&#x27;m using is for a given project.<p>EDIT: Found the benchmarks here <a href="https:&#x2F;&#x2F;pglite.dev&#x2F;benchmarks" rel="nofollow">https:&#x2F;&#x2F;pglite.dev&#x2F;benchmarks</a>
评论 #41226652 未加载
AIDataWhiz9 个月前
This is exactly the tool I needed and I will try it out in my new project. Thanks for your contribution