@lynx-js/genui/openui
English | 简体中文
@lynx-js/genui/openui is the ReactLynx client runtime for OpenUI Lang v0.5.
It parses declarative OpenUI text, evaluates reactive state and data operations,
and renders the result with a trusted ReactLynx component library.
Use this package when an Agent produces OpenUI Lang and your Lynx app owns the transport, tools, state persistence, and host actions. The Agent emits data, not executable UI code: it can only instantiate components described by the library you give to the renderer.
If you are new to OpenUI, think of it this way:
- In React, your code chooses components and passes props.
- In OpenUI, an Agent writes one assignment per line using the components in your library.
- The client parses those assignments and renders the real ReactLynx components you registered.
Install
Install the published GenUI package in a ReactLynx app:
The default catalog uses the headless behavior primitives from
@lynx-js/lynx-ui and the semantic visual tokens from
@lynx-js/luna-styles. The built-in Button, CheckBox, Modal,
RadioGroup, Slider, and TextField components use the lynx-ui primitives.
Import Luna before the OpenUI token adapter, then apply a Luna theme class
around the renderer. Renderer and component CSS are included by their modules;
there is no separate renderer stylesheet to import. Luna also provides
lunaris-light and lunaris-dark when that palette is preferred.
Quick start
Create a library, pass raw OpenUI Lang to <OpenUiRenderer>, and handle actions
that need the host application.
The raw response must be OpenUI Lang, not a Markdown code fence. Every line is
an assignment, and the render entry point must be named root:
What you own
First things to know
- Prefer
<OpenUiRenderer response={...}>for OpenUI v0.5. The legacyresult={parseResult}path renders pre-parsed static trees but does not own the v0.5 query, mutation, or reactive-state runtime. - While a model is streaming, pass the accumulated response together with
isStreaming. The incremental parser keeps completed statements renderable, and built-in interactions stay disabled until the stream finishes. - Query defaults and
initialQueryResultsare available during the first synchronous render after a response completes. Prefetched results are keyed by Query assignment name, not tool name. If you also pass atoolProvider, the Query revalidates after commit and whenever reactive arguments change.Mutation()only runs through@Run(...)in an action. onActionreceives host actions such as@ToAssistant(...)and@OpenUrl(...). State steps and tool steps execute inside the runtime first.onErrorreturns structured parser, runtime, render, and tool errors suitable for an Agent correction loop.- By default,
createOpenUiLibrary()includes 26 built-in components. Additional definitions are appended, and a later component with the same name replaces the built-in implementation. includeDefaultComponents: falselimits the Library vocabulary to caller-provided definitions. The flag does not remove the default catalog from the main entry's static dependencies. When omitted built-ins must stay outside that graph, importcreateOpenUiLibraryfrom@lynx-js/genui/openui/explicitand each retained built-in from its component subpath, such as@lynx-js/genui/openui/catalog/Stack.

