Foundryrust repl

about · foundry

What it is. How it’s made.

What

Foundry is a Rust REPL that lives in your browser tab. Two modes — a single-file editor for quick scratch work, and a notebook for composing snippets cell by cell. Source persists in your browser; identical re-runs are served from an in-tab cache.

How it works

  1. You type Rust in a CodeMirror 6 editor with the lang-rust grammar.
  2. ⇧↵ sends the source to a TanStack Start server function running on Cloudflare Workers.
  3. The Worker calls play.rust-lang.org and streams the result back as a typed event stream (started → stderr/stdout → done).
  4. On a clean run, the event sequence is persisted to IndexedDB keyed by a hash of your source. Re-running the same snippet is zero-network.
  5. A Service Worker caches the static assets — once you’ve loaded the page, cached snippets work offline.

Stack

Framework
TanStack Start (React 19, SSR + streaming server functions)
Bundler
Vite 8 + Rolldown
Editor
CodeMirror 6 + @codemirror/lang-rust
Styling
Tailwind 4 (CSS-first @theme), Fraunces + IBM Plex
State
@tanstack/react-store, localStorage, IndexedDB
Compile
play.rust-lang.org /execute (swappable via FOUNDRY_COMPILE_URL)
Deploy
Cloudflare Workers + static assets (wrangler)
Offline
Service Worker, PWA installable
Tests
Vitest + jsdom + Testing Library, Playwright for E2E
Runtime
Bun (dev + scripts)

Credits

Built by Naman, pair-programmed with Cursor. Source on GitHub.

build · 1780883245867