Overview
Understand ToonUI, the recommended React + AI SDK path, and the two-package API surface.
ToonUI is a structured UI protocol for AI chat products.
It lets a model return normal markdown plus compact toon-ui blocks, while your app keeps ownership of rendering, tools, auth, persistence, and business logic.
Recommended path
Most teams should start with:
Server: @toon-ui/core
Client: @toon-ui/react
AI loop: Vercel AI SDKVercel AI SDK is the recommended documentation path because it is common, well-supported, and ergonomic for React/Next.js chat products.
It is not a hard requirement. If you use another SDK, keep the same ToonUI architecture and replace only the model/message loop.
The two packages
| Package | Where it belongs | What it owns |
|---|---|---|
@toon-ui/core | Server or shared non-React code | Active catalog, prompt generation, parser, validator, events, messages. Current local release: 2.1.7 |
@toon-ui/react | React client code | Runtime, renderer, adapter, hooks, component props. Current local release: 2.1.6 |
There is intentionally no umbrella package. Do not import React code on the server just to get protocol helpers.
The core idea
The model can only emit the standard ToonUI components your app configures.
import { createToonProtocol } from '@toon-ui/core';
const toon = createToonProtocol({
components: ['text', 'card', 'form', 'field', 'button', 'table'],
});That active catalog drives:
toon.prompttoon.rulestoon.catalog- validation against generated output
On the client, register matching React components:
'use client';
import { createToonReactRuntime } from '@toon-ui/react';
const toon = createToonReactRuntime({
components: {
text: TextComponent,
card: CardComponent,
form: FormComponent,
field: FieldComponent,
button: ButtonComponent,
table: TableComponent,
},
});If the AI emits a component outside the active catalog, ToonUI rejects it instead of silently rendering unsupported UI.
Data capture rules
ToonUI is a DSL, so structure is part of the contract:
fieldnodes collect structured values only inside aform.- If a
dialog,sheet,popover, orcardneeds input, nest aforminside that container. - Use
description="..."for short guidance on supported containers such ascard,form,alert,confirm,dialog,item,empty, andchart. - Use
value="..."to prefill a field. Do not represent input values as nestedtext.
dialog "Contact customer" trigger="Open contact form" description="Send a message to the customer.":
form "Customer message" description="Write the message the customer will receive.":
field message textarea "Message" placeholder="Type your message..." required
button primary "Send message" submitWhat ToonUI is not
ToonUI is not:
- an agent framework
- a tool executor
- a backend workflow engine
- a v0-style frontend generator
- an alternative to JSON renderers like json-render.dev
- runtime React generation for production
- a replacement for your design system
The model describes semantic UI. Your app decides what behavior happens next.
Learning path
Read in this order:
Next step
Go to Start Here.