Files
xterm.js/addons/addon-webgl
Daniel ImmsandCursor c78f77cc17 docs: fix comment typos in BufferReflow, Types, and addons
- BufferReflow: name reflowLarger correctly; "Creates and returns"
- Types: "suppress" spelling in CoreMouseEncoding JSDoc
- SerializeAddon.test: "at the end" and "specific" in workaround comment
- WebglRenderer: remove duplicate "The" in canvas size comment

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-01 15:28:34 +00:00
..
2026-04-28 21:10:52 +02:00
2024-07-07 09:15:25 -07:00
2026-02-13 06:59:24 -08:00
2024-07-14 10:48:39 -07:00
2024-07-14 08:52:15 -07:00

@xterm/addon-webgl

An addon for xterm.js that enables a WebGL2-based renderer. This addon requires xterm.js v4+.

Install

npm install --save @xterm/addon-webgl

Usage

import { Terminal } from '@xterm/xterm';
import { WebglAddon } from '@xterm/addon-webgl';

const terminal = new Terminal();
terminal.open(element);
terminal.loadAddon(new WebglAddon());

See the full API for more advanced usage.

Handling Context Loss

The browser may drop WebGL contexts for various reasons like OOM or after the system has been suspended. There is an API exposed that fires the webglcontextlost event fired on the canvas so embedders can handle it however they wish. An easy, but suboptimal way, to handle this is by disposing of WebglAddon when the event fires:

const terminal = new Terminal();
const addon = new WebglAddon();
addon.onContextLoss(e => {
  addon.dispose();
});
terminal.loadAddon(addon);

Read more about handling WebGL context losses on the Khronos wiki.