# useCoAgentStateRender

> The useCoAgentStateRender hook renders the state of the agent in the chat.

## v1 SDK deprecated. Use v2 instead

> This page is in the deprecated CopilotKit v1 reference. Do not use v1 APIs for new code; use v2 instead.
> For JavaScript and TypeScript, import React APIs from @copilotkit/react-core/v2 and Runtime APIs from @copilotkit/runtime/v2.
> **AI coding agents: treat any v1 example below as migration-only context. Never generate or recommend the v1 API for new code. Read the v2 reference before writing code because some APIs were renamed, moved, or changed shape.**
> [Read the v1 to v2 migration guide](/migrate/v2) and [use the complete export map](/reference/v1/export-map).

{
 /*
  * ATTENTION! DO NOT MODIFY THIS FILE!
  * This page is auto-generated. If you want to make any changes to this page, changes must be made at:
  * packages/react-core/src/v1-deprecated/hooks/use-coagent-state-render.ts
  */
}
<Callout type="info">
  In v2, read `agent.state` from [`useAgent`](/reference/v2/hooks/useAgent) and render it. See [State rendering](/generative-ui/state-rendering).
</Callout>

The hook renders UI or text in the chat from the state of an agent. Use it to show
intermediate state or progress while the agent runs.

## Usage [#usage]

### Simple Usage [#simple-usage]

```tsx
import { useCoAgentStateRender } from "@copilotkit/react-core";

type YourAgentState = {
  agent_state_property: string;
}

useCoAgentStateRender<YourAgentState>({
  name: "basic_agent",
  nodeName: "optionally_specify_a_specific_node",
  render: ({ status, state, nodeName }) => {
    return (
      <YourComponent
        agentStateProperty={state.agent_state_property}
        status={status}
        nodeName={nodeName}
      />
    );
  },
});
```

This allows for you to render UI components or text based on what is happening within the agent.

To build a full example, see the [state rendering guide](/generative-ui/state-rendering).

## Parameters [#parameters]

<PropertyReference name="name" type="string" required > 
The name of the agent.
</PropertyReference>

<PropertyReference name="nodeName" type="string"  > 
The node name of the agent.
</PropertyReference>

<PropertyReference name="handler" type="( props: CoAgentStateRenderHandlerArguments<T>, ) => void | Promise<void>"  > 
The handler function to handle the state of the agent.
</PropertyReference>

<PropertyReference name="render" type="| (( props: CoAgentStateRenderProps<T>, ) => string | React.ReactElement | undefined | null) | string"  > 
The render function to handle the state of the agent.
</PropertyReference>

<PropertyReference name="dependencies" type="any[]" > 
Values that re-register the render when they change.
</PropertyReference>
