Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Turso 3 min read Announcement mediumAdept

Introducing Turso in the Browser

Turso, a from-scratch SQLite rewrite, now runs in the browser via WebAssembly as the npm package @tursodatabase/database-wasm, with a better-sqlite3-like API whose methods are all async because of OPFS. Query compute runs on the main UI thread, since benchmarks showed offloading to a worker cost too much in communication overhead. A Web Worker handles filesystem I/O through the synchronous OPFS interface and shares buffers with the main thread via SharedArrayBuffer, which requires COOP/COEP headers and locks a database to one tab. The code is compiled to wasm32-wasip1-threads with napi-rs v3, and there are dedicated Vite and Turbopack exports plus a CDN build that inlines the WASM as base64 at the cost of a larger bundle.

Related posts

  • How We Built the Turso Shell in the Browser

    Turso mediumAdept

    Turso's SQLite-compatible database can run entirely in the browser via WebAssembly, persisting data to OPFS with no backend. The walkthrough builds a SQL shell with Vite, React and TypeScript. It covers importing from the @tursodatabase/database-wasm/vite export to work around a Vite dev-server WASM issue, and setting COOP/COEP headers so SharedArrayBuffer is available. It then builds a query executor that maps prepared-statement results into a table, and upgrades the textarea to a CodeMirror editor with SQL highlighting, autocomplete and a Mod-Enter keybinding.

  • Bringing SQLite to Vercel Functions with Turso

    Turso mediumAdept

    Turso's partial sync replicates a subset of SQLite database pages into Vercel Functions so reads run in-process with no network round-trip, while writes go to the remote Turso database for durability and consistency. On cold start the driver fetches the first 128 KiB of the SQLite file, then pulls further 128 KiB segments on demand into the ephemeral /tmp directory, so cold-start cost scales with the working set rather than total database size. The experimental @tursodatabase/vercel-experimental package also auto-provisions databases by name for database-per-tenant or per-agent-session patterns. It offers an optional local-write batching mode that trades consistency for lower write latency, and uses a waitUntil() safety net that pushes pending changes if close() is forgotten.

  • WebAssembly functions for your SQLite-compatible database

    Turso mediumAdept

    libSQL, Turso's open-contribution fork of SQLite, adds user-defined functions written in WebAssembly and registered directly from SQL with a CREATE FUNCTION ... LANGUAGE wasm statement, instead of only through SQLite's C API. WebAssembly was chosen for its sandboxing, portability, performance and wide use as a compile target from languages such as Rust and Zig. A walkthrough compiles Rust encrypt/decrypt functions with the libsql_bindgen crate or its playground and loads them as binary blobs in the libSQL shell. Functions cannot touch system resources such as time, randomness or the network, and their signatures must map to INTEGER, REAL, TEXT and BLOB types.

  • Introducing Databases Anywhere with Turso Sync

    Turso mediumAdept

    Turso Sync lets local SQLite-compatible Turso databases, in Node or in the browser via WASM, sync with Turso Cloud through push, pull and sync-aware checkpoint methods layered on the standard database API. Local changes are pushed as row-level logical mutations with Last-Push-Wins conflict resolution, and a transform hook lets developers rewrite mutations for custom merge logic. Remote changes are pulled as physical pages, so replicas converge byte-for-byte on the cloud source of truth, which rules out peer-to-peer sync. The launch also adds per-table, per-operation token permissions and external JWKS/OIDC auth (Clerk and Auth0 in beta).

  • Introducing Fast, Native Encryption in Turso Database

    Turso mediumAdept

    Turso Database, a Rust rewrite of SQLite, now supports native encryption at rest using AEAD ciphers (AEGIS-256 and AES-GCM). Each page is encrypted individually with a fresh nonce, and the nonce and auth tag are stored in SQLite's per-page reserved space. Database and WAL files are encrypted, while the 100-byte header is not. Keys are supplied per connection via URI and kept only in memory. Benchmarks with AEGIS-256 show about 6% read and 14% write latency overhead on larger databases and under 3% on total runtime, with key derivation, rekeying and encrypting existing databases still planned.

The quest for software engineering knowledge.

Look:
Layout: