In this article06 +
The Browser Is Now a Legitimate Runtime
Pyodide service workers have crossed a threshold most developers didn't expect to reach this decade: a full, production-grade Python web application running entirely in the browser — no backend, no container, no provisioned server. We're not talking about a toy demo that simulates HTTP responses with innerHTML hacks. We're talking about a real application stack, intercepting real HTTP requests, serving real HTML, CSS, and JavaScript, all from client-side WebAssembly.
Simon Willison's recent deep-dive on running Datasette entirely in the browser makes this architecture concrete. The rewrite of Datasette Lite from a web-worker hack to a full service-worker architecture is a blueprint worth studying. At NerdHeadz, we see the same pattern emerging across multiple projects — and it has serious implications for how we build preview environments, staging tools, and zero-infrastructure demos.
Why the Old Approach Broke at the Seams

The original in-browser Python trick ran the application in a Pyodide web worker and injected rendered HTML back into the page using innerHTML. It technically worked for simple cases, but script tags inside innerHTML don't execute. Any feature that relied on JavaScript — plugins, dynamic UI, visualization libraries — silently failed.
That's not a minor limitation. It means the approach couldn't replicate the actual application experience. It was always a partial clone, not the real thing.
Working on something similar? Talk to our team about your project.
Service Workers Change the Architecture Completely

Service workers solve this at the protocol level. Instead of injecting content into a page, they intercept HTTP requests at the browser's network layer and respond from client-side code. The browser doesn't know it isn't talking to a real server — because from the fetch API's perspective, it isn't.
Here's how the architecture works in practice. The parent page registers a service worker for the entire domain. It then creates an iframe that loads Datasette pages at prefixed URLs like /app/<session-id>/data/places. The service worker catches those requests and routes them through a web worker running a dedicated Pyodide instance. The session ID prefix is what makes multi-tab isolation possible — each tab gets its own random session, its own Pyodide runtime, its own plugin configuration.
The web worker is still necessary because Pyodide running inside a service worker would lose state after roughly 30 seconds in most browsers. The session-routing architecture handles this cleanly: service worker handles routing, web worker maintains state, Pyodide executes Python.
We've written before about running large inference models entirely in the browser — and this service-worker pattern is a natural complement. Browser-native compute is becoming a credible deployment target.
What You Can Actually Build With This Pattern

The practical applications go well beyond novelty. This architecture unlocks several things that were previously expensive or annoying to provide:
Shareable bug reproductions. Encode the exact application version, plugin set, and database state in a URL. Send that URL. The recipient opens it in a browser and sees the exact broken behavior — no "works on my machine," no spinning up a matching environment.
Version-specific previews. Need to demonstrate how a feature behaves in version 1.0a40 versus 1.0a43? Put the version in the URL. The correct Python package gets fetched from PyPI at load time and runs in the browser.
Plugin sandboxing. Install third-party plugins from PyPI directly into an ephemeral browser session. Test them against real data without touching your production environment or local dev setup.
SQLite version comparison. This same approach works for any dependency, not just the Python application itself. By publishing WebAssembly-compiled wheels for 163 different SQLite versions, it becomes possible to test the same SQL query against any version pair in a browser tab.
This kind of URL-addressable environment is what we think about when designing app development services for clients who need shareable, reproducible preview environments without the operational overhead of per-branch staging servers.
Nothing Here Is Specific to This One Application

The most important point in this whole architecture is that none of it is specific to Datasette. Any Python web application can run this pattern. The constraints are real but narrow: SQLite works perfectly, PostgreSQL and MySQL in WebAssembly are possible but not yet smooth. C and Rust extensions — historically the hard blocker — can now be compiled to Pyodide-compatible WebAssembly by most code-generation tools, and can be published to PyPI directly as of PEP 783.
For teams building data-heavy tools, internal dashboards, or developer-facing products, this pattern eliminates an entire class of infrastructure. No staging server to provision, no Docker image to build, no branch environment to tear down. The URL is the environment.
We've seen a similar shift in how AI-adjacent applications handle data isolation — unified vs. split database architecture decisions become simpler when the runtime itself is ephemeral and browser-scoped.
The Stack Worth Watching

The combination of Pyodide, service workers, and WebAssembly-compiled extensions represents a genuine shift in what "deploying a Python app" means. Browser-based runtimes are no longer second-class. They're fast enough, isolated enough, and capable enough to handle real production logic — at least for the class of applications that don't need persistent server-side state or heavy I/O.
The pattern will spread. Any team building Python tooling should be thinking about whether their application could offer a zero-install, URL-shareable browser version. The infrastructure cost is now close to zero.
Ready to build? NerdHeadz ships production AI in weeks, not months. Get a free estimate.
“Service workers turn the browser into a real server — not a simulation of one.”
Pyodide service workers have made it practical to run a complete server-side Python application in the browser with no meaningful loss of functionality. The session-scoped routing architecture solves multi-tab isolation cleanly, and the pattern generalizes to virtually any Python web application. For teams tired of maintaining staging infrastructure, this is the architecture worth building toward.
FAQ
Frequently asked questions
How do Pyodide service workers run a full Python app in the browser?
Pyodide compiles Python to WebAssembly, allowing it to run in the browser. Service workers intercept HTTP requests at the network layer and route them to a Pyodide instance running in a web worker, which processes the request and returns real HTML, CSS, and JavaScript — replicating full server behavior without any backend.
What is the difference between using a web worker and a service worker for Pyodide?
A web worker runs Pyodide and can simulate responses, but injecting the resulting HTML via innerHTML prevents JavaScript from executing, breaking any JS-dependent features. A service worker intercepts requests at the protocol level before they reach the browser's renderer, so the full response — including scripts and stylesheets — executes normally.
Can any Python web application run in the browser using this pattern?
Yes. The architecture is not application-specific. Any Python web app can use Pyodide and service workers to run entirely in the browser, as long as its dependencies are available as WebAssembly-compatible packages. SQLite works seamlessly; PostgreSQL and MySQL in WebAssembly are possible but less mature. C and Rust extensions can now be compiled to Pyodide-compatible WebAssembly and published to PyPI under PEP 783.
What are the practical use cases for running Python apps in the browser with Pyodide?
The primary use cases are shareable bug reproductions encoded in URLs, version-specific application previews fetched from PyPI at load time, ephemeral plugin sandboxing without touching production environments, and zero-infrastructure preview environments that eliminate per-branch staging servers entirely.
Spotted via Simon Willison from Simon Willison’s Newsletter


