APIs you already know
Browser-style events (mousedown, keydown, expose, …), an HTML canvas-like 2d context with paths, Path2D, transforms, clipping and composite ops, and requestAnimationFrame for animation.
Server-side rendering
The 2d context is backed by the XRender extension: composition, scaling, gradients, blur and glyph drawing happen on the X server, so a line of text costs about a byte per glyph on the wire.
Pure JavaScript
Built on node-x11, a pure-JS X protocol client. Text shaping (fontkit), bidi, and even glyph rasterization are JavaScript — npm install never compiles anything.
Text, widgets and GL
A TextLayout engine with wrapping and font fallback, Markdown, HTML, SVG and TeX widgets on top of it, plus an OpenGL 1.4-style context over indirect GLX.
Write X11 UIs like web pages
Install with npm install ntk, connect with a single call, and get retained window objects with DOM-style events and a canvas-like drawing context. Noisy events are coalesced into paced frames, so rendering automatically adapts to the connection — even over ssh-forwarded displays.
import { createClient } from 'ntk';
const app = await createClient();
const wnd = app.createWindow({ width: 800, height: 600, title: 'Hello' });
const ctx = wnd.getContext('2d');
wnd.on('mousemove', (ev) => {
const gradient = ctx.createRadialGradient(0, 0, 10, ev.x, ev.y, 500);
gradient.addColorStop(0, 'red');
gradient.addColorStop(0.5, 'green');
gradient.addColorStop(1, 'rgba(255, 255, 255, 0)');
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, ctx.width, ctx.height);
});
wnd.map();