useCoAgentStateRender
The useCoAgentStateRender hook allows you to render 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. Open the complete export map.
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. Open the complete export map.
The useCoAgentStateRender hook allows you to render UI or text based components on a Agentic Copilot's state in the chat. This is particularly useful for showing intermediate state or progress during Agentic Copilot operations.
Usage
Simple Usage
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.
Example
A great example of this is in our Perplexity Clone where we render the progress of an agent's internet search as it is happening. You can play around with it below or learn how to build it with the state rendering guide.
This example is hosted on Vercel and may take a few seconds to load.
Parameters
Prop
Type
Prop
Type
Prop
Type
Prop
Type