API
@natui/core entrypoint
Reference run, RunOptions, NatuiApp, components, protocol types, and advanced exports.
The primary entrypoint exports every component plus the Node-driven runtime.
run
function run(
element: ReactNode,
options?: RunOptions,
): Promise<NatuiApp>Starts the host, validates its platform, protocol, and host API handshake, sends window properties, and mounts the React element.
RunOptions
RunOptions includes optional title, width, height, minWidth, and minHeight, plus:
Prop
Type
| Property | Purpose |
|---|---|
host | Host executable string or { cmd, args? } override |
onClose | Callback for native window close |
onUncaughtError | Callback for errors React cannot recover from |
readyTimeoutMs | Startup handshake timeout override |
Without onClose, closing the native window unmounts React, sends quit, and exits the Node process.
NatuiApp
Prop
Type
| Method | Result |
|---|---|
dump() | Resolves to the current native TreeNode |
screenshot(path) | Resolves to the written PNG path |
emit(id, name, payload?) | Synthesizes a debug event |
edit(id, value) | Performs an optimistic debug edit |
update(element) | Resolves after the new tree and its synchronous effect updates settle; rejects on an uncaught render or effect error |
quit() | Unmounts, asks the host to quit, and closes transport |
Other exports
The entrypoint re-exports all components, protocol types,
PROTOCOL_VERSION, HOST_API_VERSION, ROOT_ID, Bridge,
createNatuiRenderer, spawnStdioTransport, Transport, HostCommand,
defaultHostCommand, ensureHostCommand, and installHost.