Full-featured terminal emulation core for wterm, powered by libghostty built from source.
Drop-in replacement for wterm's built-in Zig core. Implements the same TerminalCore interface with comprehensive VT emulation: proper Unicode grapheme handling, all SGR attributes, terminal modes, and more.
npm install @wterm/ghosttyimport { WTerm } from "@wterm/dom";
import { GhosttyCore } from "@wterm/ghostty";
import "@wterm/dom/css";
const core = await GhosttyCore.load();
const term = new WTerm(document.getElementById("terminal"), { core });
await term.init();import { Terminal } from "@wterm/react";
import { GhosttyCore } from "@wterm/ghostty";
import "@wterm/dom/css";
const core = await GhosttyCore.load();
function App() {
return <Terminal core={core} />;
}<script setup lang="ts">
import { Terminal } from "@wterm/vue";
import { GhosttyCore } from "@wterm/ghostty";
const core = await GhosttyCore.load();
</script>
<template>
<Terminal :core="core" />
</template>GhosttyCore.load() accepts an options object:
| Option | Type | Description |
|---|---|---|
wasmPath |
string |
Custom path to the ghostty-vt WASM binary |
scrollbackLimit |
number |
Maximum scrollback lines (default: 10000) |
The WASM binary is built from upstream ghostty-org/ghostty (v1.3.1) using it as a Zig package dependency β no third-party npm packages or pre-built binaries from other projects.
ghostty (Zig dep) β WASM patches β wasm_api.zig (~300 LOC) β ghostty-vt.wasm β TypeScript bindings
ghostty's Terminal and Page types use posix.mmap and Mach VM allocators internally, which don't exist on wasm32-freestanding. The build script applies small, targeted patches to replace these with std.heap.wasm_allocator behind comptime isWasm() checks (see scripts/patch-ghostty-wasm.sh). The patches are pinned to ghostty v1.3.1 and only touch two files: page.zig and PageList.zig.
The committed wasm/ghostty-vt.wasm binary means consumers never need Zig installed. Only maintainers rebuilding the WASM need Zig 0.15.x.
Requires Zig 0.15.x (ghostty's required version):
pnpm --filter @wterm/ghostty rebuild-wasmThis fetches the ghostty source via Zig's package manager, applies WASM compatibility patches, compiles our export layer to wasm32-freestanding, and copies the binary to wasm/.
- Edit the URL tag in
zig/build.zig.zonto the new ghostty version - Run
zig fetch <new-url>from thezig/directory to get the new hash - Update the hash in
build.zig.zon - Verify the patches in
scripts/patch-ghostty-wasm.shstill apply cleanly - Run
pnpm --filter @wterm/ghostty rebuild-wasm
| Built-in (default) | @wterm/ghostty |
|
|---|---|---|
| Bundle size | ~12 KB WASM | ~400 KB WASM |
| VT compliance | Basic VT100/VT220/xterm | Comprehensive |
| Unicode | Single codepoints | Full grapheme clusters |
| Dependencies | None | None (WASM built from source) |
| Setup | Zero-config | Requires @wterm/ghostty install |
Apache-2.0