Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI Tools · Function

createStreamableValue

Creates a server-to-client stream for any serializable value. Control it with update, appendValue, done, and error, then consume the resulting value with the corresponding RSC reading APIs.

How it works

The function creates a server-side stream whose serializable value can be returned to a client. Use update to replace the current value, appendValue to append string deltas, done to finalize it, and error to signal a client-side failure.

Syntax

createStreamableValue(value?: any): StreamableValueWrapper

Parameters

NameTypeDescription
valueanyInitial serializable value for the stream; it may be omitted.

Returns

An object containing value plus update, appendValue, done, and error methods. The value is a StreamableValue that can be returned from a Server Action.

Key points

  • The function creates a server-to-client stream.
  • Its payload may be any data supported by the RSC serialization model.
  • update replaces the stream's current value.
  • appendValue adds a string delta to the existing string value.
  • done closes the stream and may optionally establish its final value.
  • error reports a stream failure to the client.

Common mistakes

  • Always call done, because leaving the stream open keeps the response in a loading state.
  • After finalization, further updates and appends are not allowed.
  • Use appendValue only when the stream's current value is a string.

Example: Create and finalize a streamable text value

import { createStreamableValue } from '@ai-sdk/rsc';

export async function generate() {
  const stream = createStreamableValue('');
  stream.update('Hello');
  stream.done();
  return stream.value;
}

Creates a text stream, updates it once, finalizes it, and returns the value for client consumption.

When to use it

Incremental generation

Stream incremental language-model text or other generated content from a server action to a client component.

Serializable state updates

Send evolving JSON, arrays, numbers, or other serializable state while server work runs.

Progress and error signaling

Expose completion and failure states alongside a streamed response.

Interview questions

QWhat does createStreamableValue provide?

It creates a stream that sends serializable values from the server to the client. The returned value can be consumed with readStreamableValue or useStreamableValue.

Follow-up: What happens if the stream is never finalized? The client remains in a loading state because done must be called.

QHow are stream values changed?

Pass an initial serializable value, or omit the argument when no initial value is needed. The stream exposes update for replacing the current value and appendValue for adding string deltas.

Follow-up: When is appendValue unsuitable? It cannot be used unless the current stream value is a string.

QHow are completion and failure represented?

Call done with no argument to retain the current value, or pass a final value to set the ending state. Calling error marks the stream as failed, and that error is thrown when the client consumes it.

Follow-up: Can a finalized stream be changed? No; finalization prevents later updates and appends.

  • readStreamableValue
  • useStreamableValue
  • createStreamableUI

Source: AI SDK RSC: createStreamableValue. Checked 2026-10-15.