Skip to content

SQLR-42 — WASM in-browser SQL playground (/playground)#149

Merged
joaoh82 merged 1 commit into
mainfrom
sqlr-42-wasm-playground
May 31, 2026
Merged

SQLR-42 — WASM in-browser SQL playground (/playground)#149
joaoh82 merged 1 commit into
mainfrom
sqlr-42-wasm-playground

Conversation

@joaoh82
Copy link
Copy Markdown
Owner

@joaoh82 joaoh82 commented May 31, 2026

What this is

A zero-install, browser-only SQL playground that runs the full SQLRite engine entirely in WebAssembly — the highest-marketing-leverage example from the SQLR-38 umbrella. Reachable at /playground on sqlritedb.com.

Features

  • CodeMirror 6 SQL editor with highlighting + Cmd/Ctrl+Enter
  • Results grid: column types, NULL highlighting, CSV export
  • Sample datasets in one click: Pokémon (filters/aggregates), Northwind (4-table JOINs), Movies (12 films + 4-dim embeddings + an HNSW cosine index — vector search in the browser)
  • Reset DB, Share (SQL encoded in #sql= hash), Download / Upload .sql
  • Session persistence across reloads via OPFS → localStorage → none

Architecture

  • Lives in web/src/app/playground/; ships as a statically-prerendered Next route (109 kB First Load JS, CodeMirror lazy-loaded via dynamic(ssr:false)).
  • The engine is the same sqlrite-engine crate, built with wasm-pack and vendored as a pinned copy into web/public/playground/pkg/ (~752 KB gzipped, under the 4 MB budget). Loaded with a runtime import() kept external from the bundler (wasm-pack's import.meta.url glue doesn't survive webpack).
  • Standalone write-up + known limitations: examples/wasm-playground/README.md.

Scope decision (recorded on SQLR-42)

The WASM Database is in-memory only with no serialization, so a binary .sqlrite byte image can't be produced in the browser today. Per discussion, v1 persists the SQL script (replayed on reload) and downloads/uploads .sql. Binary .sqlrite round-trip (needs an in-memory pager backend + Database.export()/import()) is filed as SQLR-71. ask is omitted (needs a server key).

Testing

  • wasm-pack build · tsc · next lint · next build (51 pages)
  • 12/12 headless-browser e2e (puppeteer-core → system Chrome vs next start): boot+OPFS badge, all 3 datasets incl. HNSW KNN, error pane, CSV + .sql downloads, #sql= share round-trip, persistence-across-reload, reset, Cmd+Enter.
  • Caught & fixed a real bug: Northwind sample used a two-key ORDER BY (engine supports single-key only).
  • Not verified: real Safari/Firefox matrix (OPFS fallback is feature-detected + documented), exact Lighthouse scores, Vercel deploy.

Notes

  • sdk/wasm/Cargo.lock refreshed by the build (stale 0.1.230.10.2).
  • Pre-existing site-wide /favicon.ico 404 is unrelated to this PR.

🤖 Generated with Claude Code

A zero-install browser SQL playground running the full SQLRite engine in
WebAssembly. CodeMirror 6 editor, sample datasets (Pokémon, Northwind
multi-table JOINs, Movies + HNSW cosine vector search), results grid with
column types / NULL highlighting / CSV export, share-via-URL-hash, and OPFS
session persistence via SQL-script replay. Embedded at /playground on
sqlritedb.com with a homepage card + hero CTA and a nav link.

- Rebuilt sdk/wasm and vendored the pinned pkg into web/public/playground/pkg
  (~752 KB gzipped, under the 4 MB budget); loaded via an external runtime
  import() kept out of the bundler.
- Persistence is script-replay, not binary .sqlrite — the WASM SDK is
  in-memory with no serialization. Binary round-trip tracked in SQLR-71.
- Examples page (shipped card + JSON-LD), sitemap, and READMEs updated;
  OG/Twitter images added. sdk/wasm/Cargo.lock refreshed by the build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rust-sqlite Ready Ready Preview, Comment May 31, 2026 2:03pm

Request Review

@joaoh82 joaoh82 merged commit 0b40dc7 into main May 31, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant