Skip to content

How can i get isLoading / isStreaming when using ai/rsc generative UI? #1384

Closed Answered by vucinatim
vucinatim asked this question in Help
Discussion options

You must be logged in to vote

I found out the answer by myself but with some hardship since there are no official examples of this.

You need to use StreamableValue

// action.tsx
const progressState = createStreamableValue({
  isStreaming: true,
});

...

//Somewhere in the callbacks:
progressState.done({ isStreaming: false });

...

return { id: Date.now(), display: ui, progressState: progressState.value };
// page.tsx
const [data, error, pending] = useStreamableValue(
  messages[messages.length - 1]?.progressState
);

//...

<ChatInput
  multiModal
  isLoading={data?.isStreaming || false} // How can we get this?
  input={inputValue}
  handleSubmit={handleSubmit}
  handleInputChange={(event) => {
    setInputValue(event.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fjun99
Comment options

Answer selected by vucinatim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants