What is generative UI?
Definition
Generative UI is an interface that a model assembles at run time. Instead of replying with text, the model picks components or layouts, fills them with data, and streams them to the client, which renders them. Many designs let the model choose only from a fixed catalog of approved components.
How does generative UI work?
The model does not draw pixels. It makes a choice, and your code renders it. Three current designs show the range.
| Design | What the model sends | Who writes the UI code | Where it runs |
|---|---|---|---|
| Tool results to components (Vercel AI SDK) | A tool call with arguments | You: one React component per tool | Your app |
| Declarative messages (A2UI) | JSON messages that name registered components | You: the components in the catalog | Native renderer on the client |
| Interactive app in chat (MCP Apps) | A call to a tool whose description points to a ui:// resource | You: an HTML app served by the MCP server | Sandboxed iframe in the host |
In the AI SDK, the docs define it plainly: "Generative UI is the process of connecting the results of a tool call to a React component" (AI SDK docs, last changed 2026-06-01). The model decides when to call a tool, and the tool returns data. Your component renders it. Each tool part has states such as input-available, output-available and output-error, so the screen can show loading and failure.
The flow in four steps:
- You register tools and the component for each one.
- The model reads the request and calls a tool, for example a weather or order-status tool.
- Your code runs the tool and streams the result to the client.
- The client renders the matching component for the current state.
How is it different from a chat that returns text?
A text reply makes the user read and decide. A generated interface can show a table to sort, a form with validation, or a button that starts an action. The MCP docs give the reason: text "can only go so far", and a form that shows all options at once beats a back-and-forth about region, instance size and autoscaling (MCP Apps overview).
It is also not a coding agent. A coding agent writes source code that engineers review before release. Generative UI composes a screen per request, with no review step in between. That is why the catalog and the validation matter.
What is a component catalog and why does it matter?
A catalog is the list of components, props and actions the model may use. A2UI states it directly: "Agents place only components you registered", and the page adds that agents stream "declarative JSON data ... never executable code" (A2UI). The spec says most production apps define their own catalog, and functions are catalog-defined abstractions that avoid sending raw executable code (A2UI v1.0 spec, last updated 2026-06-08).
The catalog gives you three things: a consistent look, a security boundary, and something to test.
What does a catalog check look like in code?
Model output is untrusted input. Here is a small validator in plain Node that accepts only catalog components, known props and allowed actions. We wrote it as an illustration of the idea, not as the A2UI format. Run on 2026-12-05 with Node.js 22.9.0 (node validate.mjs):
const catalog = {
Card: { props: { title: "string" }, children: true },
Text: { props: { text: "string" }, children: false },
Button: { props: { label: "string", action: "string" }, children: false },
};
const allowedActions = new Set(["refund.start", "order.track"]);
export function validate(node, path = "root") {
const errors = [];
const spec = catalog[node.component];
if (!spec) return [`${path}: unknown component "${node.component}"`];
for (const [k, t] of Object.entries(node.props ?? {})) {
if (!(k in spec.props)) errors.push(`${path}: unknown prop "${k}"`);
else if (typeof t !== spec.props[k]) errors.push(`${path}: prop "${k}" must be ${spec.props[k]}`);
}
if (node.component === "Button" && !allowedActions.has(node.props?.action))
errors.push(`${path}: action "${node.props?.action}" is not allowed`);
if (node.children && !spec.children) errors.push(`${path}: ${node.component} takes no children`);
(node.children ?? []).forEach((c, i) => errors.push(...validate(c, `${path}.${i}`)));
return errors;
}
A valid order card returned no errors. A card with a Script component, a Button bound to account.delete and a Text with a style prop returned:
- root.0: unknown component "Script"
- root.1: action "account.delete" is not allowed
- root.2: unknown prop "style"
The point: the model can ask for anything, but only listed components and actions reach the screen. A real build would use a schema library and the renderer's own validation.
What are the risks?
- Consistency. Two users can see different layouts for the same question. Keep the catalog small and put spacing and type in the components. The model chooses only content and order.
- Accessibility. The model can pick a valid but poor combination, such as a chart with no text alternative. Build accessibility into each component, so every output inherits it.
- Security. Models can be steered by prompt injection. Restrict actions to an allow list, and require confirmation for anything that changes data. MCP Apps add a sandboxed iframe that cannot read the host's cookies or DOM (MCP Apps overview).
- Version drift. AI SDK tool parts follow the
tool-${toolName}pattern from version 5.0 onward, so code written for older versions needs updating. - Support. MCP Apps is an extension, and the MCP docs say host support varies by client.
How do you test a UI that changes per user?
You cannot snapshot every output, so test the layers.
- Contract tests. Run the validator on recorded model outputs, including bad ones, as in the example above.
- Component tests. Test every catalog component alone, with states for loading, error and empty data.
- Accessibility checks. Run automated checks and keyboard tests on each component, then on a set of recorded generated screens.
- End-to-end tests. Pin the model's output with a recorded fixture, then test the flow. For live-model runs, assert on structure and actions, not wording or position. See end-to-end testing.
For the behavior layer under such components (focus, keyboard, popups), our post on Vercel UI SDK tests a library built for agents to drive.
When should you use generative UI?
Use it when the right screen depends on the request: data exploration, configuration with many options, or a support flow that ends in an action. Skip it when the screen is fixed, such as checkout or sign-in. A normal page is faster, cheaper and easier to certify.
If you are weighing this for a product, our product design and generative AI teams can help you choose the catalog and the test plan. Engineers review every component before it joins the catalog.
Sources
- Generative user interfaces, Vercel AI SDK docs, 2026-06-01
- A2UI v1.0 protocol specification, A2UI project, 2026-06-08
- A2UI: generative UI framework, A2UI project, 2026-06-08
- MCP Apps overview, Model Context Protocol, 2026-09-01
- SEP-1865: MCP Apps specification, Model Context Protocol, 2026-01-26
Frequently asked questions
Is generative UI the same as AI code generation?
No. Code generation produces source files that a developer reviews and ships. Generative UI composes an interface for one user, in one session, while the app runs.
Does the model write HTML and JavaScript?
Usually not. In the A2UI and AI SDK designs the model sends data that names components from a list you control. MCP Apps instead ship HTML that you wrote, rendered in a sandboxed iframe.
How do you test an interface that changes for every user?
Test the contract, not the pixels. Validate every model output against the catalog, test each catalog component on its own, and run accessibility checks on a set of recorded outputs.
Is generative UI safe for production?
It can be, if the model can only choose registered components and approved actions, and your code validates every output. Treat the model's output as untrusted input, like a form submission.
Services
Related terms
Mikhail BodnarchukFounder of Codeception and CodeceptJSBoth are open-source testing frameworks: Codeception for PHP, CodeceptJS for JavaScript.LinkedInGitHub