Supabase has recently unveiled a new tool that brings the power of Postgres directly to the browser. This innovative product allows developers to run a fully functional Postgres database locally, without needing any server or installation. Powered by WebAssembly (Wasm), it enables rapid prototyping, development, and even learning Postgres, all within a browser environment.
Why This Matters
Traditionally, running a database like Postgres required server setups or local installations, which could be cumbersome for quick experiments or learning. With Supabase’s new tool, you can now spin up a Postgres instance instantly, directly in your browser, making it incredibly convenient for developers to test queries, design schemas, and explore Postgres features without any setup overhead.
Who Can Benefit?
Postgres.new tool pairs Pglite with a large language model (currently GPT-4o) and gives it full reign over the database with no restricted permissions or confirmations required from the user.
Drag-and-drop a CSV file directly onto the chat to instantly receive a new table with the data automatically imported into it. The language model will scan the CSV’s header and a few sample rows to decide which data types to use for each column.
ER Diagrams are generated after the language model spits out create and alter statements and executes those statements against the running instance in the browser, it’s intuitive and rather straght forward.
ElectricSQL has been working hard to support real Postgres extensions in PGlite (compiled to WASM). One extension that was high on the priority list was pgvector which enables in-browser vector search.
Charts are a first-class feature within the chat. By simply adding the word “chart” (or similar) to the message, AI will execute the appropriate query using SQL then build a chart representing that data:
Chart created based on the generated SQL
For a fictive partner dealbook software, I inputed following natural language command to the model
“Create a partner dealbook schema. The user can put their own member benefits in the platform, import benefits from other companies”.
And then proceeded with another query to create organization level hiearchy.
“a partner account can be managed by multiple users that reside inside an organization that is created when a root user registers its account.”
The result is the following schema that the tool created.
Schema created by postgres.new tool
Here is the migration file generated from the queries above:
This is already good enough for quick schema prototyping, it seems that the days you had to make an ER diagram and then create SQL statements based on that diagram are gone. Now with one natural query, the LLM generates the necessary SQL statements executes those in the instance running inside the browser and ER diagram of that schema is generated.
PGlite is a WASM (web assembly) build of Postgres packaged into a TypeScript/JavaScript client library. You can use it to run Postgres in the browser, Node.js, and Bun with no additional dependencies.
GitHub — electric-sql/pglite: Lightweight Postgres packaged as WASM into a TypeScript library for…
_Lightweight Postgres packaged as WASM into a TypeScript library for the browser, Node.js, Bun and Deno from…_github.com
This provides a number of use cases where it might be better than a full Postgres database:
PGlite supports multiple backends for data persistence:
Postgres normally runs under a multi-process forking model, each client connection is handed off to a child process by the postmaster process. However, in WASM there is no support for forking processes, and limited support for threads.
Postgres has a relatively unknown built-in “single user mode” that is both single-process, and single-threaded. This is primarily designed to enable bootstrapping a new database, or for disaster recovery.
PGlite builds on the single user mode by adding Postgres wire protocol support, as standard Postgres only supports a minimal basic cancel REPL in single user mode. You can read more from the original blog post.
In conclusion, Supabase’s new tool is a significant advancement for developers, educators, and learners alike. This tool helps to streamline workflows, making it easier than ever to prototype, teach, and learn database concepts without the need for complex setups. Whether you’re testing queries or designing schemas, this innovation opens up new possibilities for working with Postgres in a lightweight, accessible environment.
We at Codeks are excited on using this tool to quickly prototype on new ideas for our clients.
Tired of starting from scratch when you want to build a new thing? Try out Codepilot, the ultimate SaaS Starter Kit with all the features you need to build websites fast, in addition if you need help with quickly implementing MVP, don’t hesitate to reach out.
Ready to transform your digital landscape? Contact Codeks today to book a free consultation. Let's embark on a journey to innovation, excellence, and success together.