Skip to main content

ntk API documentation

ntk is a node.js desktop UI toolkit for X11: thin wrappers around node-x11 exposing familiar, browser-like APIs — DOM-style events, an HTML canvas-like 2d context (backed by the XRender extension, so composition happens server-side) and an OpenGL 1.4-style context over indirect GLX.

These documents describe the public API surface. They must be kept in sync with the code — any change to a public API requires updating the matching file here (see AGENTS.md).

Sections

  • Getting started — installation, requirements, first window
  • App — connecting to the X server, the App factory object
  • Window — window creation, properties, methods, events, keyboard input, frame pacing / event coalescing, requestAnimationFrame
  • Pixmap — offscreen drawables
  • Clipboardapp.clipboard.write()/read(): text transfer over the CLIPBOARD/PRIMARY selections (ICCCM), INCR-aware reads
  • 2d rendering context — canvas-like drawing API over XRender
  • Images — PNG/JPEG loading (loadImage), the Image object, drawImage
  • Fonts — font lookup, loading, rasterization pipeline
  • Text — shaping (kerning/bidi/fallback), TextLayout, MarkdownView, wire-efficiency design, the vector (trapezoid) path for large/animated sizes
  • TeX / math — KaTeX-based formula rendering: layoutTex, TexView, markdown math fences
  • HTML widgetHtmlView: static HTML + CSS subset, yoga-layout flexbox/block layout, links, images, the resource-loading safety model
  • SVG widgetSvgView: static SVG rendering through the 2d context (shapes, gradients, transforms, use), plus Path2D/SVG path data
  • OpenGL rendering context — indirect GLX / OpenGL 1.4 API
  • Raw X11 rendering context — core X drawing requests
  • Resource managementusing / Symbol.dispose, GC-based cleanup
  • Headless X server — run ntk against node-x11's pure-JS X server (XRender built in since x11 3.1.0) — no DISPLAY needed