NatUI
API

Transport API

Reference the NatUI transport contract and standard-stream host implementation.

Transport

Prop

Type

interface Transport {
  send(msg: OutboundMessage): void;
  onMessage(cb: (msg: InboundMessage) => void): void;
  onExit(cb: (code: number | null) => void): void;
  close(): void;
}

A transport delivers typed protocol messages in both directions and reports host exit.

HostCommand

Prop

Type

interface HostCommand {
  cmd: string;
  args?: string[];
}

spawnStdioTransport

function spawnStdioTransport(host: HostCommand): Transport

Spawns a host process and exchanges newline-delimited JSON over its standard input and output. Host standard error is inherited for diagnostics.

defaultHostCommand

Checks NATUI_HOST first, then searches upward from the current directory for known macOS or Windows build outputs.

The shipped host process protocol uses standard streams. natui/inproc provides a separate internal transport for an embedding host.

On this page