Overview
Therender() function mounts a JSX VNode tree and sets it as the application root. It works with the automatic JSX transform to create declarative UIs with signal-driven reactivity.
Functions
render()
Mount a VNode tree and set it as the application root.The root JSX element to mount. Must resolve to a widget-bearing node (not a Fragment).
The Kraken application instance (from
Kraken.init()).Instance — The mounted instance tree with cleanup bookkeeping.
render() requires a root element that resolves to a native widget. You cannot use a bare Fragment or a component that returns only a Fragment as the root.mount()
Mount a VNode recursively, creating native widgets and binding props. Used internally byrender() and the reconciler.
The virtual node to mount.
The parent instance, or
null for root elements.Instance — The mounted instance with widget handle and cleanup bookkeeping.
Behavior:
- For Fragments: mounts children directly into parent (no native node created)
- For component functions: calls the function and mounts the returned tree
- For intrinsic elements (
Box,Text, etc.): creates native widget via FFI - Signal props are bound using
effect()from@preact/signals-core - Children are mounted recursively in declaration order
unmount()
Unmount an instance: dispose signal effects, unregister event handlers, then destroy the native subtree.The instance to unmount.
void
Lifecycle:
- Recursively dispose all
effect()cleanups (prevents FFI calls after destruction) - Clear event handler registry entries
- Destroy native nodes via
destroySubtree()(one FFI call per widget-bearing node) - For Fragments (no widget), recurse into children individually
In typical applications, you don’t need to call
unmount() manually — just call app.shutdown() which cleans up all native resources.JSX Factory Setup
Kraken uses a custom JSX runtime compatible with React’s automatic JSX transform (ADR-T20).tsconfig.json
- Use the automatic JSX transform (no
React.createElementneeded) - Import the
jsxandjsxsfunctions fromkraken-tui/jsx-runtime
Manual JSX Import (if not using automatic transform)
If you cannot use the automatic transform, import the factory manually:VNode Structure
The JSX factory produces VNode descriptors:"Box","Text", etc. for intrinsic elementsFragmentsymbol for child-only grouping- Component function for custom components
Props object (excluding
children and key).Optional key for reconciliation. Defaults to
null (positional matching).Normalized child VNodes (always an array, empty if no children).
Instance Bookkeeping
Mounted instances track signal effects and event handlers for cleanup:Fragment Behavior
Fragments have no native widget — children are mounted directly into the nearest widget-bearing ancestor.Component Functions
Component functions receive props and return a VNode:See Also
- signals.mdx — Signal-driven reactivity with
signal(),computed(),effect() - reconciler.mdx — Keyed reconciliation algorithm
- createLoop() — Animation-aware event loop for JSX apps