liveBook · Manning

createStreamableValue

As explained in Build AI-Enhanced Web Apps

A Vercel AI SDK function that creates a value whose updates can be delivered incrementally through a stream.

createStreamableValue creates a server-managed value that can be updated repeatedly and streamed to a client in real time, making incrementally generated AI responses visible before completion. section 4.1.2

A server action typically uses it in this sequence:

  • Create the streamable value after selecting a supported AI model. section 4.1.2
  • Call streamText with conversation history and obtain its textStream. section 4.1.2
  • Update the streamable value for each generated text chunk, then call done(). section 4.1.2
  • Return stream.value alongside the existing messages so the client can render the live response. section 4.1.2
Listing 4.1 Server action that creates a streamable conversation
'use server';    #1
import { streamText } from 'ai';
import { createStreamableValue } from 'ai/rsc';    #2

export async function 
continueConversation(history, provider, model) {
  'use server';
  const supportedModel = getSupportedModel(provider, model);
  const stream = createStreamableValue();    #3
  (async () => {
    const { textStream } = await streamText({
      model:  supportedModel,
      system: "I'm happy to assist you in any way I can. 
How can I be of service today?",
      messages: history,
    });

    for await (const text of textStream) {   #4
      stream.update(text);
    }

    stream.done();
  })();

  return {   #5
    messages: history,
    newMessage: stream.value,
  };
}

Inspect the complete server action connecting createStreamableValue, streamText, asynchronous iteration, and the returned conversation state. section 4.1.2

How Build AI-Enhanced Web Apps covers it

How deep it goes
Explains creation, chunk updates, completion, and returned values, but does not describe the helper's internal implementation.
Examples
Uses a continueConversation server action that streams text chunks from an AI model into a chat response.
What it assumes
Assumes familiarity with server actions, conversation history, supported model selection, and streamText.
What you can do after
Build a responsive RSC chat response that renders AI-generated text while generation remains in progress.
How it connects
Connects server actions, React Server Components, streamText, AI models, and conversation state.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI-Enhanced Web Apps. The section links point to the parts of the book it draws on.