Skip to main content

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.
AI SDK RSC is currently experimental. We recommend using AI SDK UI for production applications.

Core Concepts

The AI SDK RSC package provides three main capabilities:

1. Streaming UI Components

Stream React components directly from language model responses using streamUI and createStreamableUI.

2. State Management

Manage both AI state (conversation history) and UI state (rendered components) using createAI.

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 models
  • createStreamableUI: Manually create streamable UI components
  • createStreamableValue: Create streamable primitive values
  • getAIState: Access current AI state
  • getMutableAIState: Access and modify AI state
  • createAI: Create AI context provider

Client-Side APIs

  • useUIState: Access UI state on the client
  • useAIState: Access AI state on the client
  • useActions: Access server actions on the client
  • useStreamableValue: Read streamable values on the client
  • readStreamableValue: 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:
  1. Execute AI operations on the server
  2. Stream React components to the client
  3. Maintain state synchronization between server and client
  4. Enable progressive rendering of AI-generated content

Next Steps