Live since

DuckDB WASM Demo

A full SQL database running inside your browser tab. Walk through a small analysis, then write your own queries.

DuckDB WASM Demo on a phone
What it does

SQL with Nothing to Install

A SELECT * FROM vehicles LIMIT 5 query and its results table with log, vehicle, record type, mileage, and date columns
01

A Real Database in a Browser Tab

DuckDB is an analytics database that runs in process. Its C++ code is compiled to WebAssembly, so typical database work happens directly in the browser.

Query results showing each fill-up date and mileage next to the previous fill-up's date and mileage
02

A Small Analysis, Step by Step

Explore a dataset that records vehicle mileage and fuel prices. Each step runs more advanced SQL against it, up to window functions, to show what the full engine can do.

Sample query buttons above an editable SQL query that counts records and fill-ups per vehicle, with a Run query button and results
03

Bring Your Own SQL

After the walkthrough, the database stays live. Pick a sample query or write your own against the sample data. Nothing leaves your machine.

By the numbers

At a Glance

11 KBdataset
~6 MBengine download
3tables from one CSV
0backend servers
How it's built

What Happens When the Page Loads

  1. Page LoadsHTML and JS from NGINX
  2. Engine DownloadDuckDB WASM via jsDelivr
  3. Web WorkerStarted from a Blob URL
  4. CSV to TableOne DuckDB command
  5. QueriesResults in the page

Built with

DuckDBWebAssemblyWeb WorkersWater.cssjsDelivrNGINX
Key takeaway

Browsers won't start a Web Worker from a cross-origin URL, even with CORS headers. A Blob that calls importScripts() on the CDN script, passed to URL.createObjectURL(), gives a same-origin URL that works.

Build Notes

Challenges, learnings, and what's next

Challenges

  • Initializing the DuckDB engine in the browser adds noticeable load time to pages.
  • DuckDB and WASM are fairly new tools that many developers haven't used yet.

Learnings

  • WASM is more approachable than expected, especially when JavaScript wrappers and WASM binaries are available from a CDN.
  • Web Workers cannot be created using cross-origin URLs. The Worker() constructor strictly enforces a same-origin policy, regardless of CORS headers.
  • Window functions are a powerful part of the SQL standard, and DuckDB supports them well for analytical queries.

Next

  • Explore the practical dataset size limits of this architecture.
  • Compare WASM query performance against native query performance.
  • Use Parquet files hosted on a remote server, allowing DuckDB to fetch only the relevant row groups via HTTP range requests.
Keep exploring

More Apps