coder/ghostty-web: Ghostty for the web with xterm.js API compatibility

npm version npm download npm bundle size license

Ghosty for web with xterm.js API compatibility – provides you with a proper VT100 implementation in the browser.

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

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

  • Live demo on an ephemeral VM (thanks to Greg from Disco.Cloud for hosting).

  • On your computer:

    npx @ghostty-web/demo@next

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

haunted

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

Issue xterm.js ghost trap
complex script (Devanagari, Arabic) rendering of issues ✓ Proper grapheme handling
XTPUSHSGR/XTPOPSGR not supported ✓ Full support

xterm.js re-implements terminal emulation in JavaScript. Every escape sequence, every edge case, every Unicode quirk – all coded by hand. Ghosty’s emulator is the same battle-tested code that runs the original Ghosty app.

Ghosty-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);

broad client <-> For a server example, see the demo.

Ghosty-Web is built from Ghosty’s source with a patch to expose additional functionality.

Zig and bun required.

Michelle Hashimoto (author of Ghosty) libghostty Which makes all this possible. Due to the work done by the Ghosty team the patches are very short, and we expect them to become smaller.

Once available this library will eventually consume a native Ghosty WASM distribution, and continue to provide an xterm.js compatible API.

We’re big fans of Ghosty at Coder, so congratulations to that team for all the amazing work.

MIT



<a href

Leave a Comment