If you’ve ever worked with Postgres, you’ve probably launched psql at least once. It’s the default database client packaged with the Postgres se

psql from the browser

submited by
Style Pass
2024-12-11 21:00:05

If you’ve ever worked with Postgres, you’ve probably launched psql at least once. It’s the default database client packaged with the Postgres server. This is a command-line application, written in C, and it’s packed with many features such as autocompletion, command history, and data export/import.

psql is very popular in the Postgres community, and many developers use it daily. So, we decided to explore the possibility of running it in the browser.

This idea was born during one of our internal Neon hackathons. We occasionally hold these to explore new ideas in a fast, non-production environment without fear of breaking things. 

Technically, that’s correct. Postgres relies on the TCP stack, which isn’t accessible from the browser environment. However, at Neon, we’ve deployed a WebSocket proxy that allows users to connect to their databases directly from browser-like environments. (Initially, we built this for serverless environments without TCP stack access, like Cloudflare Workers.)

We also developed a serverless driver to act as a client for the WebSocket proxy. It works great in many JavaScript environments—Node, Vercel Edge, Cloudflare Workers—and browsers!

Leave a Comment