Back to Copilotkit

renderToIR

showcase/shell-docs/src/content/reference/channels/functions/renderToIR.mdx

1.64.21021 B
Original Source

renderToIR(renderable) expands fragments and function components into an array of intrinsic ChannelNode values.

Signature

ts
function renderToIR(ui: Renderable): ChannelNode[];
ts
type Renderable =
  | string
  | ChannelNode
  | ChannelNode[]
  | { raw: unknown };

Example

tsx
import { Header, Message, renderToIR } from "@copilotkit/channels/ui";

const ir = renderToIR(
  <Message>
    <Header>Incident update</Header>
  </Message>,
);

The runtime calls this automatically before binding callbacks and rendering a message. Use it directly for component tests or a custom adapter.

Strings—and numbers used as component children—become text nodes. false, null, and undefined render nothing. Function components are evaluated immediately, so keep them pure and free of provider side effects.

The { raw } escape hatch produces a provider-specific raw node. Managed Slack can pass native blocks through; the Teams renderer skips unknown raw content. It is not portable.