Requirements#
| Tested | Notes | |
|---|---|---|
| Next.js | 16.2.6 repository; 16.4.6 clean consumer | App Router; other versions require consumer verification. |
| Vite | 8.3.8 clean React consumer | Renderer-only path, src/ layout and @/* alias; TypeScript 7.0.2. |
| React | 19 | |
| Tailwind CSS | v4 | Blocks use container queries (@container, @lg:), built into v4. |
| shadcn/ui | Radix primitives | Initialize the host with Radix (pnpm dlx shadcn@latest init --base radix --preset nova). Base UI and React Aria are not compatible with the current blocks. |
| AI SDK | 7 (ai, @ai-sdk/react) | Needed for the chat adapter and starter; direct renderer imports do not use it. |
Prefer to let your coding agent do it? Copy a prompt from Agent setup.
Render JSON in an existing panel#
You can render host-provided JSON without changing your backend or adopting the chat shell:
The new fable-renderer registry item installs the renderer and blocks without the AI SDK. It currently includes Recharts. The optional fable-ai item adds the AI SDK tool, prompt and tool-part adapter. The existing fable-ui item remains the convenience bundle.
These items must be served from a built registry. For a local checkout, run pnpm registry:build and serve public/r; install <registry-origin>/r/fable-renderer.json using pnpm dlx shadcn@latest add. The public registry URLs are not yet verified for release; use your local registry until deployment is checked.
"use client"
import { FableProvider, FableRenderer } from "@/components/fable-ui/renderer-only"
export function ResearchPanel() {
return (
<FableProvider>
<FableRenderer id="research-summary" spec={{ blocks: [
{ type: "heading", text: "Research summary" },
{ type: "markdown", text: "Your application's data goes here." },
] }} />
</FableProvider>
)
}The renderer validates the spec. Your app owns loading, errors, cancellation and data fetching. For partial JSON, set streaming only while receiving data, then set it to false on completion, cancellation or failure. The renderer settles valid blocks and removes incomplete blocks. Diagnostics are opt-in with debug; the renderer does not depend on Node environment globals.
Use a unique, stable id for surfaces that must retain edits across remounts. Omitted IDs isolate mounted renderer instances. State lives only for the lifetime of the surrounding provider; it is not saved to browser storage. Blocks currently use positional identity: replacing or reordering mutable content requires a new surface ID to avoid reusing another block's edits.
Option A — a complete chat (new apps)#
pnpm dlx shadcn@latest add https://fable-ui.shobky.com/r/fable-chat.json
This installs the blocks plus:
| File | What it is |
|---|---|
app/fable-chat/page.tsx | The chat page |
app/api/fable-chat/route.ts | The AI SDK route with the render_ui tool |
components/fable-ui/chat/* | Thread, message and composer |
Add your key to .env.local (the CLI adds the variable names):
OPENAI_API_KEY=sk-...
FABLE_MODEL=gpt-5.5To use another provider, install it (pnpm add @ai-sdk/anthropic) and change one line in the route:
import { anthropic } from "@ai-sdk/anthropic"
const model = anthropic("claude-sonnet-5-5")Open /fable-chat and ask for something structured, such as "Compare three note-taking apps in a table".
Option B — your existing chat#
pnpm dlx shadcn@latest add https://fable-ui.shobky.com/r/fable-ui.json
Server. Add the tool and the prompt to your streamText call:
import { convertToModelMessages, hasToolCall, stepCountIs, streamText } from "ai"
import { fableSystemPrompt } from "@/components/fable-ui/prompt"
import { FABLE_TOOL_NAME, fableTool } from "@/components/fable-ui/tool"
const result = streamText({
model,
system: [yourInstructions, fableSystemPrompt()].join("\n\n"),
messages: await convertToModelMessages(messages),
tools: { ...yourTools, [FABLE_TOOL_NAME]: fableTool },
// The UI is the answer: stop once it is shown.
stopWhen: [hasToolCall(FABLE_TOOL_NAME), stepCountIs(5)],
})Client. Render the tool part and give Fable a way to send replies:
import { FableProvider, FableToolPart, isFableToolPart } from "@/components/fable-ui"
const busy = status === "submitted" || status === "streaming"
<FableProvider onReply={(text) => sendMessage({ text })} readOnly={busy}>
{message.parts.map((part, index) =>
isFableToolPart(part) ? (
<FableToolPart key={part.toolCallId} part={part} active={busy && message.id === activeMessageId} />
) : <YourPart key={index} part={part} />
)}
</FableProvider>Derive activeMessageId from your host's currently streaming assistant response. Historical parts must receive active={false}, including while a later response is streaming. On stop, transport failure or history replay, idle parts settle and show an interruption notice when appropriate. Keep your existing transport, history and authentication. Registered host actions still require server validation and authorization.
Fonts and themes#
Headings use font-heading. If your global CSS doesn't define it yet, add this line to the @theme inline block:
--font-heading: var(--fable-font-heading, var(--font-sans));Fable reads your existing shadcn variables, so it already matches your theme. For the six presets, see Theming.
Edge cases#
- Windows / PowerShell: if
pnpmis blocked by the execution policy, usepnpm.cmd dlx shadcn@latest add …. - Existing files: the CLI asks before overwriting. Don't pass
--overwritefor files you changed. - Path aliases: imports use
@/components/...and@/lib/utils. Keepcomponents.jsonaliases in sync withtsconfig.json. - Runtime: the starter uses the host's route runtime. Verify your provider and dependencies before selecting Edge.
- Long histories: every past spec is sent back to the model. The route keeps the last 40 messages; lower it if your answers are large.
- Images: nothing loads from a host you haven't allowed. See Security.