Ghostty in the browser
ghostty-webgpu runs Ghostty’s unpatched libghostty-vt terminal emulator in WebAssembly and pairs it with a browser host and four renderers. Use it to embed interactive shells, build logs, or local command prompts without re-implementing VT parsing in JavaScript.
Install the package, mount a fitted terminal in ten lines, and try a live prompt.
Connect a real shellSpawn Bash in a Bun PTY and stream raw bytes over a binary WebSocket.
Migrating from xterm.jsMap constructors, byte I/O, built-in fit, and addon replacements.
Run in a workerMove parsing, frame building, and GPU rendering onto OffscreenCanvas.
How the pieces fit together
Section titled “How the pieces fit together”One native libghostty-vt instance owns escape parsing, active screen state, modes, scrollback, selection coordinates, and Unicode cell widths. Four renderers read from that single source of truth:
- WebGPU and WebGL2 consume persistent cell and glyph buffers built in Zig (
bridge.wasm) and upload only dirty byte ranges. - Canvas 2D paints frame one immediately while WebGPU or WebGL2 compiles its shaders in the background, then hands off in place without flashing. It also serves as the fallback when neither GPU API is available.
- DOM renders plain styled rows when Canvas is unavailable or explicitly chosen through
rendererFactory.
await terminal.open(host) measures the container synchronously before constructing the renderer, so terminal.appearance.grid and terminal.geometry() already hold the fitted column and row counts as soon as open() resolves.
Entry points
Section titled “Entry points”Pick the package entry point that matches where your code runs:
| Entry point | Environment | Purpose |
|---|---|---|
ghostty-webgpu | Browser | Main-thread Terminal host with automatic fitting, selection, links, scrollback, and Canvas-first GPU startup. |
ghostty-webgpu/worker | Browser | Runs libghostty-vt, Zig frame building, and WebGPU or WebGL2 rendering in a dedicated worker or TerminalWorkerPool on OffscreenCanvas. |
ghostty-webgpu/core | Browser or Node | Headless GhosttyRuntime, GhosttyTerminal, and TerminalSession with no DOM or renderer imports. |
ghostty-webgpu/hotkeys | Browser | Optional Ghostty keymap adapter (attachTerminalHotkeys) backed by @shaulavo/hotkeys. |
ghostty-webgpu/config-resolver | Node or Bun | Resolves host Ghostty config files into terminal appearance objects. |
Current scope and limits
Section titled “Current scope and limits”Shipped features include DEC mode 2026 synchronized output, mode 2027 grapheme clustering, opt-in GSUB ligatures (ligatures), lazy Unicode 13.0 BiDi (bidi), OSC 8 hyperlinks, URL detection, and an opt-in screen-reader text mirror (accessibility: {}).
Retained-buffer search, Sixel and Kitty image protocols, and a formal screen-reader audit remain open work. See status and limits and the changelog for release notes.