Thursday, November 19, 2026 Updated Briefings Saved 中文
AI Daily Radar

AI and the frontier tech around it, explained every morning

Datasette Lite Runs the Full App in Browser via Service Workers

Photo: Monoar_CGI_Artist / Pixabay

A clear, first-hand explanation of rewriting Datasette Lite to run the full server-side Python app in the browser via service workers and Pyodide, presenting a transferable architecture pattern for WebAssembly preview environments.

Background

Datasette Lite, first launched in 2022, originally ran the server-side Datasette app in a Pyodide web worker and injected the resulting HTML into the page with innerHTML. That let basic pages work, but script tags in innerHTML do not execute, so JavaScript-dependent features and extra CSS or JavaScript assets failed.

Solution

The rewrite registers a service worker for all of lite.datasette.io; an iframe requests normal Datasette URLs prefixed with /app//, and the worker routes each request through the parent page to a dedicated Pyodide web worker. The per-tab session prefix prevents tabs sharing the domain-wide service worker from colliding when each URL asks for different plugins or settings. A web worker is still required because, the author says, Pyodide inside a service worker cannot retain state beyond roughly 30 seconds depending on the browser. Carefully composed URLs can install PyPI or wheel-file plugins, load databases, JSON, CSV, SQL or metadata, and select a released Datasette version or a GitHub ref; the author uses these links to demonstrate bugs and work-in-progress features. A later ?sqlite= parameter resolves one of 163 WebAssembly-compiled pysqlite3 wheels, making it possible to test Datasette against specific SQLite releases, while the author notes non-SQLite databases remain harder and the system has many moving parts.

Takeaway

The author argues the architecture is not Datasette-specific: any Python app could use WebAssembly and Pyodide for cheap preview and debugging environments, with C and Rust extensions increasingly compilable and PEP 783 allowing Wasm wheels on PyPI.

Comments

Comments

Comments use a GitHub account and are moderated. Comment rules

More in Deep Dives

See all