ajcwebdev
Podcast cover art for Run Your Database in the Browser with Postgres

Run Your Database in the Browser with Postgres

Published:

A lively discussion about running Postgres in the browser with Snaplet's open-source approach, leveraging WebAssembly.

Episode Description

A lively discussion about running Postgres in the browser with Snaplet’s open-source approach, leveraging WebAssembly.

Episode Summary

This episode delves into the innovative effort by Snaplet and Supabase to bring Postgres into the browser using WebAssembly and an x86 emulation layer. After introducing the main guests and their backgrounds in frameworks like Redwood.js, the conversation centers on how running a Postgres server directly in the browser can simplify setup, accelerate development workflows, and enable powerful educational use cases. Key topics include the technical hurdles of packaging Postgres with a lightweight Linux system, the possibilities for combining multiple browser-based services, and the security implications of networking constraints. The guests also explore potential future directions, such as local development with realistic data snapshots and real-time collaboration through WebRTC. Overall, the episode spotlights a pioneering approach that may herald a new wave of browser-based server technologies.

Chapters

00:00 - 06:00 — Welcome and Opening Banter

In this introductory segment, the hosts kick off the show and set the stage for an in-depth discussion about running databases in the browser. They chat about guest invitations, playful banter on avatar icons, and the behind-the-scenes mechanics of hosting a live Twitter Space. Listeners get a feel for the relaxed yet curious environment, where both seasoned developers and newcomers are encouraged to join. The hosts also mention their ongoing efforts to spread knowledge, encouraging audience members to request the mic and share opinions or ask questions. These first few minutes underscore the show’s inclusive nature, inviting participants from all skill levels to engage with both everyday JavaScript and cutting-edge web technologies.

06:00 - 12:00 — Snaplet Introduction and Redwood.js Roots

This portion focuses on Peter’s background and how he initially got involved with Redwood.js before founding Snaplet. He discusses how his collaboration with well-known figures like Tom Preston-Werner and Scott Chacon led to the creation of Redwood, illustrating the deep experience he brings to Snaplet. The conversation shifts to Snaplet’s core mission: enabling developers to easily access realistic, privacy-compliant data for local development. By explaining Snaplet’s capacity to capture and transform production databases into secure, developer-friendly snapshots, Peter paints a picture of a tool that addresses common headaches in data replication. Listeners gain valuable insight into the origin story of a product driven by real-world frustrations with incomplete or outdated development data.

12:00 - 18:00 — Inspiration from Crunchy Data and the Call to Open Source

Here, the discussion turns to the inspiration behind running Postgres in the browser. Peter recounts seeing Crunchy Data’s demonstration of a WebAssembly-based Postgres, which sparked his own vision for an open-source version. Despite minimal initial traction when posting about the idea, a serendipitous connection with Supabase CEO Paul Copplestone led to immediate collaboration. Snaplet’s engineers joined forces with Supabase to create a community-driven approach that would be fully transparent and available for developers to inspect and modify. This segment highlights the power of open-source collaboration, the excitement around early prototypes, and the spark that ultimately propelled the project to reality.

18:00 - 24:00 — Running Postgres in the Browser: The WASM Angle

During these minutes, the hosts and guests break down the basics of WebAssembly (WASM) and how it can serve as a compile target for languages other than JavaScript. They clarify that while the Postgres codebase wasn’t directly ported to WASM, the team leveraged V86, an x86 emulator running within the browser. This clever approach allows developers to bypass some of the lower-level complexities of directly compiling C/C++ to WASM. The panel discusses possible misconceptions about WASM—emphasizing that it’s often a transpilation target rather than something developers write in directly—and underscores the potential for browser-based apps that were once thought to be impossible to deploy on the client side.

24:00 - 30:00 — The V86 Emulation Strategy: Pros and Cons

Attention now turns to the pros and cons of using a virtual machine on top of WebAssembly rather than compiling Postgres natively. The hosts explore performance trade-offs, memory constraints, and how multiple layers of abstraction might impact the user experience. On the flip side, the approach is surprisingly generic: any Linux-based software could theoretically run via this method, significantly broadening the scope for future projects. Participants talk about how “standing on the shoulders of giants” in the form of advanced open-source tools allows Snaplet and Supabase to build quickly while still keeping the final project accessible and free for the community.

30:00 - 36:00 — Envisioning the Future: Composability and Edge Cases

In this chapter, the guests go deeper into potential use cases for a browser-based database. They imagine a world in which multiple browser tabs serve as microservices or individual pieces of a distributed system, each running its own WASM-powered component. The notion of easily pausing and resuming system snapshots also arises, hinting at new avenues for debugging and testing. Beyond developer convenience, the panel muses on how such composability might shape collaborative tools, where real-time adjustments can be made across numerous sandboxed environments. The conversation underscores the sense of endless possibility, tempered by practical questions around performance and security.

36:00 - 42:00 — Technical Hurdles: Building Linux Images and Beyond

Here, the conversation centers on the nuts and bolts of preparing a minimal Linux environment to host Postgres in the browser. The Snaplet team explains how they utilized Buildroot to create ultra-small, efficient system images. These custom images skip conventional boot procedures by snapshotting the CPU and memory state at just the right moment, allowing near-instant “boot” times in the browser. The difficulties of iterative builds—where each attempt could take hours—come to light, offering a glimpse into the relentless trial and error of advanced software R&D. The audience gains a deeper appreciation for the specialized knowledge required to shrink large systems into compact, embeddable browser packages.

42:00 - 48:00 — Practical Examples and the Magic of One-Click Demos

During this segment, the team walks through how a developer can instantly spin up Postgres in the browser simply by opening a URL. They emphasize the difference between a typical local setup process—installation woes, random startup failures, and manual configuration—and the frictionless environment of a browser tab. The conversation touches on external connectivity, demonstrating how a live browser session can share its database over the internet through a WebSocket proxy. Real-world scenarios like building educational tutorials, ephemeral sandboxes, and ephemeral local dev environments come into focus, showing the immediate, tangible benefits of the project’s “click and go” philosophy.

48:00 - 54:00 — Overcoming Connection Limits and WebSocket Proxies

Now, the discussion tackles the inherent networking limitations of browsers. The panel explains that direct TCP/IP connections are not possible under typical browser security models, so a Python-based WebSocket proxy is employed to enable remote connections. They talk about the necessity for some external server to relay messages, referencing potential expansions via WebRTC for peer-to-peer connectivity. Listeners also hear about constraints within the WebAssembly sandbox and how solutions like local file APIs or drag-and-drop might eventually open new data-sharing workflows. This part of the show spotlights the interplay between deep technical constraints and the creative solutions that push boundaries forward.

54:00 - 60:00 — Snaplet’s Vision and Data-Centric Use Cases

During these minutes, the focus shifts to how these breakthroughs could reshape the Snaplet roadmap. Peter discusses the prospect of offering ephemeral, browser-based databases preloaded with sanitized production data for debugging and testing. By avoiding burdensome local installations and complex configuration, developers can quickly iterate on realistic datasets. The conversation covers Snaplet’s broader mission of bridging the gap between production and development, preventing data inaccuracies from triggering bugs down the line. The guests also revisit the idea of “pausable” database states, which could drastically streamline the shipping of new features or reproducing legacy environment states for comparison.

60:00 - 66:00 — Community Reception and the Hacker News Wave

In this section, the conversation highlights the unexpectedly enthusiastic community response. The project soared to number one on Hacker News, remaining on the front page for an extended period. The panel shares anecdotes about mostly positive feedback, with just one lonely commenter offering a skeptical take. Metrics like GitHub stars serve as an initial barometer for success, and the guests reflect on how the developer community’s excitement can fuel further innovation. They also touch on how tools like Snaplet and Supabase could evolve thanks to this momentum, urging others to join their Discord and contribute ideas or code to the open-source repository.

66:00 - 73:29 — Audience Q&A and Closing Thoughts

The final stretch features a brief audience Q&A, where listeners raise both technical and philosophical points. One caller praises the so-called “cheating” approach of using x86 emulation as an inspired workaround, highlighting how pushing WASM’s boundaries can transform “impossible” ideas into reality. Wrapping up, the panel reiterates the importance of open-source collaboration, acknowledging that this Postgres-in-the-browser effort may well be the tip of the iceberg. They encourage everyone to continue experimenting, file issues, and join the Snaplet Discord for deeper engagement. With warm farewells, the hosts thank participants for an informative and future-looking episode, inviting them to return for more live JavaScript and web development discussions each week.