Data Components in TypeScript SDK
Copy page
Define data component schemas for rich, interactive agent messages using the TypeScript SDK.
What are Data Components?
Data Components allow your agents to return rich, interactive content instead of just text. Think of them as reusable UI building blocks that your agent can populate with data.
For example, instead of returning "You have 3 tasks: Task #123 (shipped), Task #124 (processing)...", your agent can return a properly formatted task list component.
Defining Data Components
Data components are defined using the dataComponent builder function. We recommend using Zod schemas for type safety and better developer experience.
JSON Schema is also supported if you prefer traditional schema definitions.
Using in Agents
Register data components with your agent:
When a user asks "Show me my tasks", the agent will respond with:
Response Shape
A response from a dataComponents-enabled agent can take three shapes, exposed on the agent_generate data operation as generationType:
object_generation— only data components, no prose (the example above).text_generation— only text. The framework returns the model's prose if it does not produce a valid structured object, so users see the response instead of a blank message.mixed_generation— text and one or more data components in the same message.partsis ordered by emission, so a reasoning prelude can precede a component, narration can sit between components, or commentary can follow them.
The agent_generate event records parts with type: 'text' | 'data_component' | 'data_artifact' (plus 'tool_call' | 'tool_result' for internal tool events). Iterate parts in order and render each entry by its type. See Data Operations for the full event shape.
Frontend Integration
Create a React component that receives the props defined by your data component schema:
Register the component with the chat widget.
The agent will automatically return structured data that renders as your React component.