Solution skill
Generative UI: render tool results as React components
Complete solution
Guide Generative UI: render tool results as React components: Render a loading state for the call phase and the real component when output is available. Generative UI means the model does not just write text; it picks components. Use this when you hit exactly this in Generative UI. Not for different errors or different tools.
TL;DR: Render a loading state for the call phase and the real component when output is available. Generative UI means the model does not just write text; it picks components. The mechanism is tools plus tool-part rendering.
Generative UI means the model does not just write text; it picks components. The mechanism is tools plus tool-part rendering.
Server: define a tool per UI element.
import { tool } from 'ai'; import { z } from 'zod';
const tools = { getWeather: tool({ description: 'Get the weather for a city', inputSchema: z.object({ city: z.string() }), execute: async ({ city }) => ({ city, temp: 62, condition: 'sunny' }), }), };
const result = streamText({ model: 'your-model-id', tools, messages: await convertToModelMessages(messages) });
Client: render tool parts as components.
{messages.map(m => ( [div key [your value]] {m.parts.map((part, i) => { if (part.type === 'text') return [span key [your value]] if (part.type === 'tool-getWeather' && part.state === 'output-available') { return [WeatherCard key [your value] data={part.output} /]; } if (part.type === 'tool-getWeather') return [WeatherSkeleton key [your value] /]; return null; })} [/div] ))}
Rules:
- Tool parts start as calls and become results. Render a loading state for the call phase and the real component when output is available. Check the part state field; do not assume output exists.
- Keep execute fast or stream-friendly. A 10-second tool blocks its UI region; consider client-side tools with onToolCall for interactive ones.
- Dynamic tool parts (dynamic tools) let the model call tools not in your static map. Render a generic fallback for unknown tool parts instead of crashing.
- The tool description drives when the model picks the component. Write descriptions as UI triggers: "Use this when the user asks about weather; renders a weather card."
- Validate tool output before rendering. A component that crashes on unexpected output takes down the whole message list. Error boundaries per card are cheap insurance.
- For confirmation-style interactions (book this flight?), use a client tool with addToolOutput instead of auto-executing server-side.
When to use
You hit exactly this: Generative UI: render tool results as React components in Generative UI.
When not to use
A different error, or the same symptom in a different tool. This page only covers the failure above.
Compatibility
Generative UI.
Evidence
Verified against the live AI SDK docs 2026-09-26. The generative-user-interfaces guide documents the tools-to-components flow: model calls tool, tool executes, data passes to a React component, with the useChat plus tool parts pattern. The chatbot tool-usage guide documents server auto-executed tools, client tools with onToolCall/addToolOutput, and tool parts on message.parts.
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_WYxmkYPt6AIGG8Yk1_2Hvg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Generative UI: render tool results as React components <span>— Vectle</span></a>