ntk
node.js desktop UI toolkit
ntk is a node.js desktop UI toolkit for X11
A set of wrappers around node-x11 that simplifies X Window UI programming with web like APIs, including 2D and 3D graphics.
What ntk provides
ntk is a node.js desktop UI toolkit for X11. The README describes it as a set of wrappers around the low level node-x11 module that simplify X Window UI programming, covering window creation, DOM style event handling, and 2D or 3D graphics, using API concepts familiar from the web. The goal is to let a JavaScript developer build native X11 windows without writing raw X protocol code. A key property is that everything, including font rasterization, is pure JavaScript, so npm install never compiles anything. That keeps installation simple compared with toolkits that need native builds. The README points to a docs and live playground site where ordinary ntk code runs in the browser against node-x11's in browser pure JavaScript X server, with XRender included and bundled fonts, and the same server also works headless in node for running apps and tests without a real X server. Beyond windows and events, ntk offers a 2D canvas that implements the HTML context2d API through the XRender extension, and 3D graphics through indirect GLX with most of the OpenGL 1.4 API. High level widgets and layout management are expected to live outside ntk, likely in a React renderer such as react-x11, keeping the core focused on the drawing and window primitives.
Installation and basic usage
Installing ntk is a single command: npm install ntk. The README states it requires Node.js 20.19 or later and an X server. Full documentation lives in the docs directory, starting from docs/README.md. Because the toolkit is pure JavaScript, there is no compilation step during install, which keeps the setup light. Basic usage starts by creating a client and a window. The example imports createClient from ntk, awaits it to get an app, then calls app.createWindow with a width, height, and title. Events attach with methods such as wnd.on, where a mousedown handler can read the event coordinates and update the title. Calling wnd.map makes the window visible. This mirrors the event model web developers already know, which is the point of the wrapper. For headless testing, the in browser X server mentioned in the README can run the same code without a display. The 3D path needs an X server with indirect GLX enabled, which the README notes is disabled by default on many systems and must be turned on for OpenGL to work. Server side resources can be managed with using or await using syntax on Node 24 or later, so a pixmap or connection is freed automatically when the block ends.
2d graphics through XRender
The 2D graphics layer is one of ntk's main features. Each window or pixmap can create a 2D canvas that implements the HTML context2d API through the XRender extension. That means a developer uses familiar calls such as paths made of arcs and Beziers, a Path2D built from SVG path data, non zero and even odd fill rules, transforms with save and restore, clipping, globalAlpha, and Porter Duff composite operations. The README references docs/context-2d.md for the full surface. Most operations run on the X server side, including image composition, scaling, blur, text composition, and gradients. Text is fully shaped in pure JavaScript, with OpenType kerning and ligatures, complex scripts through bidi-js, and automatic font fallback, then rasterized by a built in scanline rasterizer and cached server side as XRender glyphs, so drawing a line of text costs about a byte per glyph on the wire. Font names resolve through fontconfig with fc-match. Very large and continuously animated sizes render as server side trapezoids instead of cached bitmaps. A TextLayout engine wraps styled text to a target width, documented in docs/text.md. PNG and JPEG images decode client side and composite server side through ctx.drawImage, documented in docs/images.md, and an SvgView widget renders static SVG through the same pipeline.
Editorial conclusion
ntk installs with npm install ntk and requires Node.js 20.19 or later plus an X server. Everything including font rasterization is pure JavaScript, and a live playground runs ordinary ntk code in the browser against an in browser X server.
Community notes