use Lang Graph Interrupt
The useLangGraphInterrupt hook allows setting the generative UI to be displayed on LangGraph's Interrupt event.
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.
useLangGraphInterrupt is still supported, but we recommend migrating to useInterrupt from the v2 API. useInterrupt uses the same render: ({ event, resolve }) => ... pattern to render UI for an interrupt and resume the agent with the user's response. In v2, event.value can arrive as a JSON string. Parse it before you read its fields.
useLangGraphInterrupt is a React hook that you can use in your application to provide
custom UI to be rendered when using interrupt by LangGraph.
When LangGraph emits an interrupt, the hook renders your component. The user answers in it, and resolve sends the answer back to the agent.
Usage
Simple Usage
import { useLangGraphInterrupt } from "@copilotkit/react-core";
// ...
const YourMainContent = () => {
// ...
// styles omitted for brevity
useLangGraphInterrupt<string>({
render: ({ event, resolve }) => (
<div>
<p>{event.value}</p>
<form onSubmit={(e) => {
e.preventDefault();
resolve((e.target as HTMLFormElement).response.value);
}}>
<input type="text" name="response" placeholder="Enter your response" />
<button type="submit">Submit</button>
</form>
</div>
)
});
// ...
return <div>{/* ... */}</div>
}Parameters
Prop
Type
How is this guide?