Generative UI
Learn how to embed embed custom UI components in the chat window.
Specify "use client"
(Next.js App Router)
This is only necessary if you are using Next.js with the App Router.
Like other React hooks such as useState
and useEffect
, this is a client-side hook.
If you're using Next.js with the App Router, you'll need to add the "use client"
directive at the top of any file using this hook.
Render custom react components in the chat UI
useCopilotAction
can be used with a render
function and without a handler
to display information or UI elements within the chat.
Here's an example to render a calendar meeting.
Test it out!
After defining the action with a render method, ask the copilot to perform the task. For example, you can now ask the copilot to "show tasks" and see the custom UI component rendered in the chat interface.
You can read more about the useCopilotAction
hook here.