MCPcopy Index your code
hub / github.com/coder/ghostty-web

github.com/coder/ghostty-web @v0.4.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.4.0 ↗ · + Follow
468 symbols 1,023 edges 27 files 203 documented · 43% 7 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ghostty-web

NPM Version NPM Downloads npm bundle size license

Ghostty for the web with xterm.js API compatibility — giving you a proper VT100 implementation in the browser.

  • Migrate from xterm by changing your import: @xterm/xtermghostty-web
  • WASM-compiled parser from Ghostty—the same code that runs the native app
  • Zero runtime dependencies, ~400KB WASM bundle

Originally created for Mux (a desktop app for isolated, parallel agentic development), but designed to be used anywhere.

Try It

bash npx @ghostty-web/demo@next

This starts a local HTTP server with a real shell on http://localhost:8080. Works best on Linux and macOS.

ghostty

Comparison with xterm.js

xterm.js is everywhere—VS Code, Hyper, countless web terminals. But it has fundamental issues:

Issue xterm.js ghostty-web
Complex scripts (Devanagari, Arabic) Rendering issues ✓ Proper grapheme handling
XTPUSHSGR/XTPOPSGR Not supported ✓ Full support

xterm.js reimplements terminal emulation in JavaScript. Every escape sequence, every edge case, every Unicode quirk—all hand-coded. Ghostty's emulator is the same battle-tested code that runs the native Ghostty app.

Installation

npm install ghostty-web

Usage

ghostty-web aims to be API-compatible with the xterm.js API.

import { init, Terminal } from 'ghostty-web';

await init();

const term = new Terminal({
  fontSize: 14,
  theme: {
    background: '#1a1b26',
    foreground: '#a9b1d6',
  },
});

term.open(document.getElementById('terminal'));
term.onData((data) => websocket.send(data));
websocket.onmessage = (e) => term.write(e.data);

For a comprehensive client <-> server example, refer to the demo.

Development

ghostty-web builds from Ghostty's source with a patch to expose additional functionality.

Requires Zig and Bun.

bun run build

Mitchell Hashimoto (author of Ghostty) has been working on libghostty which makes this all possible. The patches are very minimal thanks to the work the Ghostty team has done, and we expect them to get smaller.

This library will eventually consume a native Ghostty WASM distribution once available, and will continue to provide an xterm.js compatible API.

At Coder we're big fans of Ghostty, so kudos to that team for all the amazing work.

License

MIT

Extension points exported contracts — how you extend this code

IDisposable (Interface)
(no doc) [10 implementers]
lib/interfaces.ts
IDisposable (Interface)
(no doc) [10 implementers]
lib/types.ts
IBufferLineForUrlProvider (Interface)
* Minimal buffer line interface for URL detection [1 implementers]
lib/providers/url-regex-provider.ts
IScrollbackProvider (Interface)
(no doc) [2 implementers]
lib/renderer.ts
MockKeyboardEvent (Interface)
(no doc)
lib/input-handler.test.ts
SelectionCoordinates (Interface)
(no doc)
lib/selection-manager.ts
ITerminalForLinkDetector (Interface)
(no doc)
lib/link-detector.ts
ITerminalDimensions (Interface)
(no doc)
lib/addons/fit.ts

Core symbols most depended-on inside this repo

write
called by 223
lib/terminal.ts
dispose
called by 172
lib/types.ts
createIsolatedTerminal
called by 161
lib/test-helpers.ts
open
called by 151
lib/terminal.ts
getLine
called by 61
lib/types.ts
getScrollbackLength
called by 31
lib/renderer.ts
fire
called by 29
lib/types.ts
clearDirty
called by 26
lib/renderer.ts

Shape

Method 343
Interface 45
Class 36
Function 35
Enum 9

Languages

TypeScript100%

Modules by API surface

lib/types.ts102 symbols
lib/terminal.ts57 symbols
lib/ghostty.ts51 symbols
lib/buffer.ts48 symbols
lib/renderer.ts43 symbols
lib/interfaces.ts37 symbols
lib/selection-manager.ts33 symbols
lib/input-handler.ts15 symbols
lib/input-handler.test.ts14 symbols
lib/link-detector.ts12 symbols
lib/providers/url-regex-provider.ts9 symbols
lib/addons/fit.ts8 symbols

For agents

$ claude mcp add ghostty-web \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact