showcase/shell-docs/src/content/reference/bot/functions/renderToIR.mdx
renderToIR is the bridge from JSX to data: it recursively invokes component functions until only intrinsic string-typed nodes remain, producing the serializable BotNode[] IR an adapter translates into its native format. You rarely call it directly — thread.post renders for you — but it's the core primitive for testing components or building custom adapters.
import { renderToIR } from "@copilotkit/bot-ui";
function renderToIR(ui: Renderable): BotNode[];
import { Message, Header, renderToIR } from "@copilotkit/bot-ui";
function Greeting({ name }: { name: string }) {
return (
<Message>
<Header>Hello {name}</Header>
</Message>
);
}
const ir = renderToIR(<Greeting name="Ada" />);
// [{ type: "message", props: { children: [{ type: "header", props: { … } }] } }]
Fragment flattens its children.{ type: "text", props: { value } }; false / null / undefined render nothing (so {cond && <Section>…</Section>} works).{ raw } short-circuits: renderToIR({ raw: payload }) passes through as { type: "raw", props: { value: payload } }, for handing an adapter a native payload (e.g. hand-built Block Kit) directly.