· via dev.to (home feed)
WebDB ships a 19 KB relational query engine that compiles TypeScript straight to bytecode
WebDB, a new library from developer Ahmad Moussawi, compiles a fluent TypeScript query API straight into database bytecode, packing joins, B+Tree indexes and ACID transactions into a roughly 19 KB WASM core.

A relational engine written for the browser, not ported to it
Developer Ahmad Moussawi has released WebDB, a relational database engine built specifically for the browser rather than compiled down from a desktop database. In a November 6 post on dev.to, Moussawi frames the project as an escape from the two routes offline-first developers usually take: raw IndexedDB, which is not relational, or WebAssembly builds of desktop engines such as SQLite and PGlite, which trade convenience for large downloads and awkward hosting requirements.
Despite the name, WebDB is not a browser API. It is a JavaScript library with a WebAssembly core that the author says weighs about 19 KB gzipped (roughly 51 KB raw) — around 95% smaller than typical SQLite or Postgres WASM ports — and it ships with a pure JavaScript fallback.
No SQL strings in the query path
The central design choice is dropping SQL text entirely. Desktop databases need a SQL parser because queries arrive as strings over a network socket; in a browser tab, the application and the database share one runtime, so Moussawi argues that serialising a query into SQL only to tokenise it back into bytecode is wasted effort.
WebDB instead compiles a fluent, typed TypeScript query builder directly into the binary opcodes its virtual machine executes — the post names instructions such as OP_INDEX_SCAN and OP_RESULT_ROW — in under 0.05 ms, according to the author. With no C lexer or parser to bundle, the engine still offers B+Tree indexes, joins, aggregates, subqueries and ACID transactions.
The design also sidesteps a server configuration problem. SQLite-based WASM setups typically want SharedArrayBuffer for fast synchronous access, which requires COOP and COEP isolation headers that can break third-party scripts, embeds and authentication popups. According to the announcement, WebDB works from any static host or CDN with no special headers.
Storage, durability and multiple tabs
Under the hood, an asynchronous virtual file system suspends on 4 KB page faults across OPFS and IndexedDB. The post also highlights a more unusual capability: multi-gigabyte read-only databases can be queried directly from S3 or a CDN via HTTP Range requests, without downloading the entire file.
Durability comes from write-ahead logging with CRC32 checksums on every 4 KB page, intended to prevent corruption when a user abruptly closes a tab. Multiple tabs reading and writing the same database coordinate through navigator.locks, and the engine packs UUIDv7 and ULID identifiers into 16 raw bytes rather than 36-character strings, which the author says makes B+Tree inserts faster and fragmentation-free.
Fluent queries and live UI updates
The public API is a typed query builder: tables are declared with typed columns and composite indexes, and queries chain together joins, grouping, HAVING clauses and aggregates, with an .explain() call available to inspect the generated bytecode plan.
For UI work, the library ships bindings for React, Vue, Angular and plain JavaScript, each under 1 KB gzipped. A useLiveQuery hook inspects a query's structure — including joined tables — and re-runs it automatically when the relevant data changes, whether the write happened in the current tab, in a Worker, or in another browser tab via BroadcastChannel.
The numbers come from the author
All performance figures are self-reported: 5,000-row in-memory workloads run on a MacBook Pro M1 Max. WebDB's WASM build logged 1,091.7 operations per second on a range filter scan against 125.9 for official SQLite WASM (an 8.7x speedup), 359,152 ops/s on bulk inserts versus 156,576 (2.3x), and smaller gains on point lookups and joins. One result cuts the other way: on a filter-sort-limit workload, SQLite WASM (1,483.7 ops/s) beat WebDB's pure JS fallback (681.7 ops/s), although the WASM build was still fastest at 2,381.0 ops/s. Moussawi invites readers to run the benchmark suite themselves. The package is available as @ahmadmoussawi/webdb, alongside a browser-based Studio playground for inspecting raw pages and B+Tree structures and for sharing compressed database files.
Why it matters
Local-first and offline-first applications keep hitting the same wall: the browser's storage story works for key-value caching but not for relational workloads, and the common workaround — shipping a desktop database as multi-megabyte WASM — carries costs in bundle size, server headers and CPU. If WebDB's claims hold up beyond its author's own benchmarks, a sub-20 KB engine with joins, indexes and transactions lowers that barrier considerably, and header-free deployment removes a genuine operational headache. Querying large read-only datasets over HTTP ranges is a capability desktop ports do not naturally offer. The open questions are maturity and trust: this is a single-author project with self-reported numbers on one machine, competing against SQLite's decades of hardening and its large ecosystem of tooling.
- #local-first
- #webassembly
- #databases
- #offline-first
- #typescript