content/docs/07-reference/03-ai-sdk-rsc/07-get-mutable-ai-state.mdx
getMutableAIStateGet a mutable copy of the AI state. You can use this to update the state in the server.
<Snippet
text={import { getMutableAIState } from "@ai-sdk/rsc"}
prompt={false}
/>
<PropertiesTable content={[ { name: 'key', isOptional: true, type: 'string', description: "Returns the value of the specified key in the AI state, if it's an object.", }, ]} />
The mutable AI state.
<PropertiesTable content={[ { name: 'update', type: '(newState: any) => void', description: 'Updates the AI state with the new state.', }, { name: 'done', type: '(newState: any) => void', description: 'Updates the AI state with the new state, marks it as finalized and closes the stream.', }, ]} />
<ExampleLinks examples={[ { title: 'Learn to persist and restore states AI and UI states in Next.js', link: '/examples/next-app/state-management/save-and-restore-states', }, ]} />