Generative UI lets the AI generate complete user interfaces from natural language prompts. Instead of rendering text responses in chat bubbles, the AI output is the UI: forms, cards, dashboards, and more. The developer defines which components are available (the “catalog”), and the AI composes them into a valid UI tree. This pattern uses json-render, the Generative UI framework, to define component catalogs, generate specs with AI, and render them safely across React, Vue, Svelte, and Angular.Documentation Index
Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-mdrxyo-1777658790-7be347c.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
How it works
- Define a catalog: declare what components the AI can use, with typed props
- Prompt the AI: describe the UI you want in natural language
- AI generates a spec: a JSON document describing the component tree
- Render safely: json-render’s
Rendererrenders the spec using your components
Define a component catalog
The catalog describes every component the AI is allowed to use. Each component has a Zod schema for its props and a description that the AI reads to understand when to use it:Build a component registry
The registry maps each catalog component to its actual rendering implementation. UsedefineRegistry to get type-safe bindings between the catalog props and
your component functions:
Connect to the agent
The agent uses structured output to return a json-render spec. Set upuseStream
with your agent’s assistant ID, then extract the spec from the AI message’s
tool_calls:
Stream and render progressively
During streaming, the spec is built up incrementally. Elements arrive one at a time and may initially lacktype or props. Filter to only complete elements
and pass loading={true} to the Renderer, which tells it to silently skip
children that haven’t arrived yet. The UI builds up component by component:
The
JSONUIProvider is required to set up json-render’s internal context
providers (state, visibility, validation, actions). The Renderer component
must be rendered inside it.The spec format
The AI agent generates a flat JSON spec with aroot key pointing to the
root element and an elements map containing all components:
TextInput
and Button have empty children arrays.
Best practices
- Use descriptive component descriptions: the AI uses these to understand when to use each component. Clear descriptions lead to better UI generation.
- Validate before rendering: always check that elements have valid
typeand non-nullpropsbefore passing to the Renderer, since streaming delivers partial data. - Design for streaming: pass
loading={true}during streaming so the Renderer gracefully handles children that haven’t arrived yet. Users see the UI build up in real time rather than waiting for the full response. - Style with design tokens: use CSS custom properties so rendered components adapt to light and dark themes automatically.
- Wrap with JSONUIProvider: the
Renderermust be inside aJSONUIProviderto access json-render’s internal context for state, visibility, and actions.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

