This page is new on the main branch. 0.8.4 does not have it. Read the 0.8.4 docs.

Rust

The Rust crates drive the native renderer from Rust, without JavaScript. They are experimental and not published: build them from a checkout of the repository. The crates are in packages/rust:

  • opentui-sys declares the C ABI of opentui.h. It is generated from the header.
  • opentui wraps the ABI safely and adds widgets, an event loop, focus, input, and headless tests.
  • opentui-ssh serves apps over SSH, one app per session.

Build and test#

The crates link the native library of the same checkout. Build it first, then run Cargo from the repository root:

bun install
bun run build
cargo test --manifest-path packages/rust/Cargo.toml

bun run build:native in the core package also builds the native library. To link other artifacts, such as the directory of an npm platform package, set OPENTUI_LIB_DIR to that directory. It wins over the checkout’s build. The npm platform packages ship only the shared library, so on Linux and macOS they need the default features off (see below). Give an absolute path: Cargo reads a relative one from the opentui-sys crate’s directory.

The bindings match one exact opentui.h. The build fails when the library’s header differs from the one the bindings were generated from. After a header change, run bun run generate:abi in the core package.

On Linux and macOS the crates link the static library by default, through the default static feature, so an app needs no OpenTUI file at run time. With default-features = false (or --no-default-features) they link the shared library instead. Cargo merges features across the app’s graph, so every crate in it that depends on opentui must turn the defaults off. Windows links opentui.dll with or without the feature: ship opentui.dll beside the app’s .exe. See C for the native artifacts and the targets they support.