Refactor high-complexity React components in Dify frontend. Use when `pnpm analyze-component...
npx skills add YuniorGlez/gemini-elite-core --skill "json-render-expert"
Install specific skill from multi-skill repository
# Description
`json-render` (by Vercel Labs) is the 2026 standard for **Guardrailed AI User Interfaces**. Unlike raw LLM generations that often hallucinate or break, `json-render` forces AI models to work within a strictly defined **Catalog** of components validated by **Zod**. It specializes in **JSONL Patch Streaming**, allowing React components to render incrementally as bits of data arrive, ensuring sub-300ms perceived latency.
# SKILL.md
name: json-render-expert
description: json-render (by Vercel Labs) is the 2026 standard for Guardrailed AI User Interfaces. Unlike raw LLM generations that often hallucinate or break, json-render forces AI models to work within a strictly defined Catalog of components validated by Zod. It specializes in JSONL Patch Streaming, allowing React components to render incrementally as bits of data arrive, ensuring sub-300ms perceived latency.
π json-render-expert (v1.1.0)
Executive Summary
json-render (by Vercel Labs) is the 2026 standard for Guardrailed AI User Interfaces. Unlike raw LLM generations that often hallucinate or break, json-render forces AI models to work within a strictly defined Catalog of components validated by Zod. It specializes in JSONL Patch Streaming, allowing React components to render incrementally as bits of data arrive, ensuring sub-300ms perceived latency.
π Table of Contents
- Core Architecture
- The Catalog (The Guardrail)
- Next.js Integration
- Streaming Implementation (Native SDK)
- The "Do Not" List (Anti-Patterns)
- Standard Production Patterns
- Reference Library
π Core Architecture
json-render operates on a three-pillar system:
- @json-render/core: The engine that handles state, data binding, and JSONL patch application.
- @json-render/react: The renderer that maps JSON schema to React 19 components.
- @json-render/codegen: Tool for exporting AI-generated state into pure React code.
The "State-to-UI" Loop
- AI Model generates JSONL Patches.
JSONRenderoruseUIStreamclient accumulates patches into a Virtual State.- Components render dynamically based on the Registry whitelist.
π‘ The Catalog (The Guardrail)
The Catalog defines what the AI can build.
Defining a Component
import { z } from 'zod';
export const catalog = {
components: {
MetricCard: {
schema: z.object({
title: z.string(),
value: z.number(),
}),
description: 'Display KPIs.',
}
}
};
β‘ Next.js Integration
Optimized for Next.js 16+ App Router.
Server (app/api/render/route.ts):
import { GoogleGenAI } from "@google/genai";
export async function POST(req: Request) {
const { prompt } = await req.json();
const client = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
const result = await client.models.generateContentStream({
model: "models/gemini-3-flash-preview",
contents: [{ role: "user", parts: [{ text: prompt }] }]
});
const stream = new ReadableStream({
async start(controller) {
for await (const chunk of result.stream) {
if (chunk.text) controller.enqueue(new TextEncoder().encode(chunk.text));
}
controller.close();
}
});
return new Response(stream);
}
π€ Streaming Implementation (Native & Hook)
In 2026, we prefer the official useUIStream hook for robust parsing.
Client-side Implementation
'use client';
import { Renderer, JSONUIProvider, useUIStream } from '@json-render/react';
import { registry } from './registry';
export function AIInterface() {
const { tree, isStreaming, send } = useUIStream({ api: '/api/render' });
return (
<JSONUIProvider registry={registry}>
<Renderer
tree={tree}
registry={registry}
loading={isStreaming}
/>
</JSONUIProvider>
);
}
π« The "Do Not List" (Anti-Patterns)
| Anti-Pattern | Why it fails in 2026 | Modern Alternative |
|---|---|---|
| catalog prop in Provider | Not supported in v0.2.0 | Pass registry to JSONUIProvider instead. |
| Manual Stream Parsing | Error-prone for partial JSON | Use useUIStream hook. |
| Blocking Renders | Poor UX | Use JSONL Patch Streaming. |
| Mixing Logic | Security risk | Use Actions for logic. |
π Standard Production Patterns
Pattern A: Multi-Turn UI Updates
Send the current tree back to the AI as context to request minimal patches.
Pattern B: Registry Override
Override how a catalog component is rendered locally without changing the catalog.
Pattern C: Native Visibility
Control UI based on external factors using the VisibilityProvider context.
π Reference Library
Updated: January 22, 2026 - 19:55
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.