# useLangGraphInterrupt

> The useLangGraphInterrupt hook allows setting the generative UI to be displayed on LangGraph's Interrupt event.

## 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).

<br />
<video src="https://cdn.copilotkit.ai/docs/copilotkit/images/coagents/interrupt-flow.mp4" className="rounded-lg shadow-xl" loop playsInline controls autoPlay muted />

<Callout type="warning">
  `useLangGraphInterrupt` is still supported, but we recommend migrating to [`useInterrupt`](/reference/v2/hooks/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.
</Callout>

`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 [#usage]

### Simple Usage [#simple-usage]

```tsx title="app/page.tsx"
import { useLangGraphInterrupt } from "@copilotkit/react-core"; // [!code highlight]
// ...

const YourMainContent = () => {
  // ...
  // [!code highlight:15]
  // 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 [#parameters]

<PropertyReference name="action" type='Omit<LangGraphInterruptRender<TEventValue>, "id">' required>
  The action to perform when an Interrupt event is emitted. Either `handler` or `render` must be defined as arguments

    <PropertyReference name="handler" type="(props: LangGraphInterruptRenderHandlerProps<TEventValue>) => any | Promise<any>">
      A handler to programmatically resolve the Interrupt, or perform operations which result will be passed to the `render` method
    </PropertyReference>

    <PropertyReference name="render" type="(props: LangGraphInterruptRenderProps<T>) => string | React.ReactElement">
        Render lets you define a custom component or string to render when an Interrupt event is emitted.
    </PropertyReference>

    <PropertyReference name="enabled" type="(args: { eventValue: TEventValue; agentMetadata: AgentSession }) => boolean">
        Method that returns a boolean, indicating if the interrupt action should run. Useful when using multiple interrupts
    </PropertyReference>

    <PropertyReference name="agentId" type="string">
        Optional agent ID to scope this interrupt to a specific agent. Defaults to the agent configured in the CopilotKit chat configuration.
    </PropertyReference>
</PropertyReference>

<PropertyReference name="dependencies" type="any[]">
  An optional array of dependencies.
</PropertyReference>
