File: streaming-values.md | Updated: 11/15/2025
Menu
v5 (Latest)
AI SDK 5.x
Model Context Protocol (MCP) Tools
Copy markdown
=========================================================================================
AI SDK RSC is currently experimental. We recommend using AI SDK UI for production. For guidance on migrating from RSC to UI, see our migration guide .
The RSC API provides several utility functions to allow you to stream values from the server to the client. This is useful when you need more granular control over what you are streaming and how you are streaming it.
These utilities can also be paired with AI SDK Core
functions like streamText
and streamObject
to easily stream LLM generations from the server to the client.
There are two functions provided by the RSC API that allow you to create streamable values:
createStreamableValue
createStreamableUI
The RSC API allows you to stream serializable Javascript values from the server to the client using createStreamableValue
, such as strings, numbers, objects, and arrays.
This is useful when you want to stream:
You can import createStreamableValue from @ai-sdk/rsc and use it to create a streamable value.
'use server';
import { createStreamableValue } from '@ai-sdk/rsc';
export const runThread = async () => { const streamableStatus = createStreamableValue('thread.init');
setTimeout(() => { streamableStatus.update('thread.run.create'); streamableStatus.update('thread.run.update'); streamableStatus.update('thread.run.end'); streamableStatus.done('thread.end'); }, 1000);
return { status: streamableStatus.value, };};
You can read streamable values on the client using readStreamableValue. It returns an async iterator that yields the value of the streamable as it is updated:
import { readStreamableValue } from '@ai-sdk/rsc';import { runThread } from '@/actions';
export default function Page() { return ( <button onClick={async () => { const { status } = await runThread();
for await (const value of readStreamableValue(status)) { console.log(value); } }} > Ask </button> );}
Learn how to stream a text generation (with streamText) using the Next.js App Router and createStreamableValue in this example
.
createStreamableUI creates a stream that holds a React component. Unlike AI SDK Core APIs, this function does not call a large language model. Instead, it provides a primitive that can be used to have granular control over streaming a React component.
Let's look at how you can use the createStreamableUI function with a Server Action.
app/actions.tsx
'use server';
import { createStreamableUI } from '@ai-sdk/rsc';
export async function getWeather() { const weatherUI = createStreamableUI();
weatherUI.update(<div style={{ color: 'gray' }}>Loading...</div>);
setTimeout(() => { weatherUI.done(<div>It's a sunny day!</div>); }, 1000);
return weatherUI.value;}
First, you create a streamable UI with an empty state and then update it with a loading message. After 1 second, you mark the stream as done passing in the actual weather information as its final value. The .value property contains the actual UI that can be sent to the client.
On the client side, you can call the getWeather Server Action and render the returned UI like any other React component.
app/page.tsx
'use client';
import { useState } from 'react';import { readStreamableValue } from '@ai-sdk/rsc';import { getWeather } from '@/actions';
export default function Page() { const [weather, setWeather] = useState<React.ReactNode | null>(null);
return ( <div> <button onClick={async () => { const weatherUI = await getWeather(); setWeather(weatherUI); }} > What's the weather? </button>
{weather} </div> );}
When the button is clicked, the getWeather function is called, and the returned UI is set to the weather state and rendered on the page. Users will see the loading message first and then the actual weather information after 1 second.
Learn more about handling multiple streams in a single request in the Multiple Streamables guide.
Learn more about handling state for more complex use cases with AI/UI State .
On this page
Deploy and Scale AI Apps with Vercel.
Vercel delivers the infrastructure and developer experience you need to ship reliable AI-powered applications at scale.
Trusted by industry leaders: