AI SDK RSC Overview
AI SDK RSC provides a set of utilities for building AI-powered applications with React Server Components. It enables you to stream React components from the server to the client, manage AI and UI state, and create generative user interfaces.Core Concepts
The AI SDK RSC package provides three main capabilities:1. Streaming UI Components
Stream React components directly from language model responses usingstreamUI and createStreamableUI.
2. State Management
Manage both AI state (conversation history) and UI state (rendered components) usingcreateAI.
3. Generative UI
Generate dynamic UI components based on tool calls and model responses.Key APIs
Server-Side APIs
streamUI: Create streamable UI from language modelscreateStreamableUI: Manually create streamable UI componentscreateStreamableValue: Create streamable primitive valuesgetAIState: Access current AI stategetMutableAIState: Access and modify AI statecreateAI: Create AI context provider
Client-Side APIs
useUIState: Access UI state on the clientuseAIState: Access AI state on the clientuseActions: Access server actions on the clientuseStreamableValue: Read streamable values on the clientreadStreamableValue: Read streamable values without React
Installation
Basic Example
Here’s a complete example using AI SDK RSC:Use Cases
AI SDK RSC is particularly useful for:- Dynamic UI Generation: Create interfaces that adapt based on AI responses
- Server-Side AI Processing: Keep API keys and heavy processing on the server
- Streaming Interfaces: Show progressive results as the model generates them
- Complex Tool Integrations: Render custom components for each tool call
Architecture
The AI SDK RSC uses React Server Components to:- Execute AI operations on the server
- Stream React components to the client
- Maintain state synchronization between server and client
- Enable progressive rendering of AI-generated content
Next Steps
- Learn about Streaming React Components
- Explore Generative UI patterns
- Check the API Reference