showcase/shell-docs/src/content/docs/concepts/which-hook.mdx
CopilotKit v2 has a focused set of hooks for letting the agent do things in your app and for rendering what it does. They split into two groups: hooks that register behavior, and hooks that register how a tool call looks in the chat. Use this page as the quick map, then follow each hook to its full reference.
| Hook | Use it when you want to |
|---|---|
useFrontendTool | Give the agent a client-side tool to call (run logic in the browser), with optional inline UI. |
useRenderTool | Render the UI for a specific tool call by name (typed), without defining the tool's handler. |
useDefaultRenderTool | Provide one wildcard renderer for any tool call that has no specific renderer. |
useComponent | Register a React component as a named tool renderer (component-first generative UI). |
useHumanInTheLoop | Pause the agent on a tool call and wait for the user to approve, edit, or supply input. |
useInterrupt | Handle an agent-initiated interrupt and resume execution once the user responds. |
useRenderToolCall | Get a render function for tool calls to drive your own custom chat surface (headless). |
Start with the verb.
useFrontendTool.
You define the tool's schema and handler; the agent calls it. Add a render
to also show inline UI for the call.useRenderTool to render one named tool,
useComponent to bind a React component to a
tool name, or useDefaultRenderTool
as the catch-all for anything you didn't render explicitly.useHumanInTheLoop for tool-level
approval/edit gates, or useInterrupt for
agent-driven interrupts you resume with user input.useRenderToolCall. It returns the
renderer function so you can place tool-call output anywhere in a headless
layout.Two hooks in this set register a tool the agent can call: useFrontendTool
(schema and handler) and useComponent (a component-first
shorthand that wraps useFrontendTool internally, registering a tool whose
"handler" is rendering your component). The render-only hooks, useRenderTool,
useDefaultRenderTool, and useRenderToolCall, don't define a tool; they
only render tool calls, which can come from your frontend (useFrontendTool /
useComponent) or from the agent/backend. That's why you can pair a backend
tool with useRenderTool and never write a handler on the client.
useFrontendTool.