/vercel-ai-sdk:generative-ui-patternsfrom vercel-ai-sdk
Provides templates and patterns for implementing Generative UI with Vercel AI SDK RSC, including server-side streaming components, dynamic UI generation, and client-server coordination in Next.js App Router.
Ships in vercel-ai-sdk. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Purpose: Provide reusable templates, patterns, and validation scripts for implementing Generative UI with Vercel AI SDK RSC (React Server Components).
Activation Triggers:
Key Resources:
templates/server-action-pattern.tsx - Server action template for AI RSCtemplates/streaming-component.tsx - Streaming component patterntemplates/client-wrapper.tsx - Client component wrapper patterntemplates/route-handler.ts - API route handler for streaming UIscripts/validate-rsc-setup.sh - Validate Next.js RSC configurationscripts/generate-ui-component.sh - Generate UI component from schemaexamples/ - Real-world generative UI implementationsWhen to use: Next.js App Router with React Server Components
Template: templates/server-action-pattern.tsx
Pattern:
'use server'
import { streamUI } from 'ai/rsc'
import { openai } from '@ai-sdk/openai'
export async function generateUI(prompt: string) {
const result = await streamUI({
model: openai('gpt-4')
prompt
text: ({ content }) => <p>{content}</p>
tools: {
// Tool definitions for dynamic UI generation
}
})
return result.value
}
Key features:
When to use: Need real-time UI updates during AI generation
Template: templates/streaming-component.tsx
Pattern:
When to use: Complex interactions between client and server components
Template: templates/client-wrapper.tsx
Pattern:
# Check Next.js version and App Router setup
./scripts/validate-rsc-setup.sh
Checks:
app/ directory existsDecision tree:
# Generate component from pattern
./scripts/generate-ui-component.sh <pattern-type> <component-name>
# Examples:
./scripts/generate-ui-component.sh stream-text MessageCard
./scripts/generate-ui-component.sh dynamic-tool ChartGenerator
./scripts/generate-ui-component.sh workflow MultiStepForm
Use template: templates/server-action-pattern.tsx
Customize:
Use template: templates/client-wrapper.tsx
For:
Pattern:
const tools = {
showChart: tool({
description: 'Display data as chart'
parameters: z.object({
data: z.array(z.number())
type: z.enum(['bar', 'line', 'pie'])
})
generate: async ({ data, type }) => {
return <ChartComponent data={data} type={type} />
}
})
showTable: tool({
description: 'Display data as table'
parameters: z.object({
rows: z.array(z.record(z.string()))
})
generate: async ({ rows }) => {
return <TableComponent rows={rows} />
}
})
}
Key principle: Let AI choose appropriate UI component based on data
const result = await streamUI({
// ... config
onError: (error) => {
return <ErrorBoundary error={error} />
}
fallback: <LoadingSpinner />
})
Best practices:
Use dynamic imports for heavy components:
const HeavyChart = dynamic(() => import('./HeavyChart'))
Control chunk size for optimal UX:
const result = await streamUI({
// ... config
experimental_streamChunking: true
})
Cache static UI components:
export const revalidate = 3600 // 1 hour
Critical: Never expose server actions to client
// ✅ Good: server action
'use server'
export async function generateUI() { /* ... */ }
// ❌ Bad: client-accessible
export async function generateUI() { /* ... */ }
Always sanitize AI-generated content:
import DOMPurify from 'isomorphic-dompurify'
const sanitized = DOMPurify.sanitize(aiContent)
File structure:
app/
actions/
generate-ui.ts # Server actions
components/
ui/
generated/ # Generated UI components
client-wrapper.tsx # Client components
api/
stream-ui/
route.ts # Alternative API route pattern
Required: Proper RSC types
// tsconfig.json
{
"compilerOptions": {
"jsx": "preserve"
"lib": ["dom", "dom.iterable", "esnext"]
"module": "esnext"
"moduleResolution": "bundler"
}
}
import { generateUI } from './actions'
test('generates UI from prompt', async () => {
const ui = await generateUI('Show weather chart')
expect(ui).toMatchSnapshot()
})
Use testing-patterns skill for comprehensive streaming tests
Use case: AI generates form fields dynamically
Template: examples/multi-step-form.tsx
Use case: AI selects appropriate chart type
Template: examples/chart-generator.tsx
Use case: AI creates dashboard widgets
Template: examples/dashboard-generator.tsx
Use case: AI generates content in card layouts
Template: examples/content-cards.tsx
Scripts:
validate-rsc-setup.sh - Verify Next.js and RSC configurationgenerate-ui-component.sh - Scaffold component from patternTemplates:
server-action-pattern.tsx - Complete server action templatestreaming-component.tsx - Streaming component patternclient-wrapper.tsx - Client component wrapperroute-handler.ts - API route alternative patternExamples:
multi-step-form.tsx - Complete multi-step form implementationchart-generator.tsx - Dynamic chart generationdashboard-generator.tsx - Full dashboard examplecontent-cards.tsx - Card-based content layoutSupported Frameworks: Next.js 13.4+ (App Router only) SDK Version: Vercel AI SDK 5+ with RSC support React Version: React 18+ (Server Components)
Best Practice: Always start with validate-rsc-setup.sh to ensure environment compatibility
What SKILL.md sets; muted values are Claude Code's defaults
5 skills in this plugin
/agent-workflow-patternsAI agent workflow patterns including ReAct agents, multi-agent systems, loop control, tool orchestration, and autonomous agent architectures. Use when building AI agents, implementing workflows, creating autonomous systems, or when user mentions agents, workflows, ReAct, multi-step reasoning, loop control, agent orchestration, or autonomous AI./provider-config-validatorValidate and debug Vercel AI SDK provider configurations including API keys, environment setup, model compatibility, and rate limiting. Use when encountering provider errors, authentication failures, API key issues, missing environment variables, model compatibility problems, rate limiting errors, or when user mentions provider setup, configuration debugging, or SDK connection issues./rag-implementationnpx claudepluginhub vanman2024/ai-dev-marketplace --plugin vercel-ai-sdkOther plugins' skills for the same job