AI SDK RSCgetMutableAIState

getMutableAIState

Get a mutable copy of the AI state. You can use this to update the state in the server.

Import

import { getMutableAIState } from "ai/rsc"

Arguments

key?:

string
Returns the value of the specified key in the AI state, if it's an object.

Returns

The mutable AI state.

Methods

update:

(newState: any) => void
Updates the AI state with the new state.

done:

(newState: any) => void
Updates the AI state with the new state, marks it as finalized and closes the stream.

Examples