Chat component. Move to composition only when you need layout control.
For headless state, see Chat hooks.
Prerequisites
- A Veryfront project with an AG-UI route, such as
/api/ag-ui(see Create agent). - A configured provider for the route’s agent (see Providers).
Add the preset UI
Create a client page:useChat() connects to /api/ag-ui by default. Chat renders the composer,
message list, loading state, and scroll behavior.
Add request preprocessing
UsebeforeStream when the route needs to add context, enforce authorization,
or stop a request before the agent runs:
beforeStream
before they reach the agent. Retrieved documents are treated as reference data,
not instructions.
Customize the preset
Pass props to enable common chat features:Compose a custom layout
Use the composition components when the preset layout is too constrained:Message when individual message rendering needs custom structure:
ChatWithSidebar:
Verify it worked
Runveryfront dev and open the page that renders the chat UI:
- The composer renders and accepts input.
- A submitted message streams tokens from
/api/ag-ui. - Preset props render the expected controls.
- Custom layouts keep the message list and composer wired to the same AG-UI stream.
Next
- Chat hooks: Use headless chat state
- Memory and streaming: Configure agent memory and streaming
Related
- veryfront/chat: Chat components and hooks
- veryfront/agent: Agent route helpers