useChat. The pages in this section each own one part of that picture. This page is the map — if you’d rather read mechanics end to end, skip to How it works.
Everything below maps onto one annotated agent:
trigger/my-agent.ts
useTriggerChatTransport connects useChat to the agent’s session, no API routes (Frontend). Underneath, the conversation lives on a Session: a pair of durable streams keyed on your chatId that survives refreshes, deploys, and run boundaries.
Where each part is covered
| Part | Page |
|---|---|
chat.agent() options, the turn loop, piping | Backend |
Hooks around each turn (onTurnComplete, hydration) | Lifecycle hooks |
Declaring tools, typed payloads, toModelOutput | Tools |
useChat wiring, tokens, starting sessions | Frontend |
| Driving a chat from your server instead of a browser | Server-side chat |
| The durable substrate under every agent | Sessions |
| Per-run typed state inside the loop | chat.local |
| Type-safe payloads, client data, and messages | Types |
| Building without the managed lifecycle | Custom agents |
| End-to-end mechanics: what survives a refresh and why | How it works |

