Skip to main content
Creates a piece of changeable UI that can be streamed to the client in React Server Components. On the client side, it can be rendered as a normal React node.

Parameters

ReactNode
The initial React node to display.

Returns

Returns a StreamableUIWrapper object with the following properties and methods:
ReactNode
The value of the streamable UI. This can be returned from a Server Action and received by the client.
(value: ReactNode) => StreamableUIWrapper
This method updates the current UI node. It takes a new UI node and replaces the old one. Returns the streamable UI wrapper for chaining.
(value: ReactNode) => StreamableUIWrapper
This method is used to append a new UI node to the end of the old one. Once a new UI node is appended, the previous UI node cannot be updated anymore. Returns the streamable UI wrapper for chaining.
(error: any) => StreamableUIWrapper
This method is used to signal that there is an error in the UI stream. It will be thrown on the client side and caught by the nearest error boundary component. Returns the streamable UI wrapper for chaining.
(...args: [ReactNode] | []) => StreamableUIWrapper
This method marks the UI node as finalized. You can either call it without any parameters or with a new UI node as the final state. Once called, the UI node cannot be updated or appended anymore.This method is always required to be called, otherwise the response will be stuck in a loading state.Returns the streamable UI wrapper for chaining.

Examples

Basic usage

Progressive updates

Appending nodes

Error handling

Streaming with LLM

Complex progressive rendering

Important Notes

You must always call .done() on the streamable UI, otherwise the client will remain in a loading state indefinitely.
The streamable UI must be used within a Server Action or Server Component context in Next.js.
If you don’t call .done() within a reasonable time (default: 3 seconds in development), you’ll see a warning in the console.