Keep your UI in sync
Your UI updates the moment the assistant changes data
When the AI modifies data through tool calls, your UI should update. The useYakToolEvent hook lets you subscribe to tool completions and invalidate caches—your page refreshes automatically after chatbot actions.
What you get
- Subscribe to tool call completion events
- Access tool name, args, result, and success status
- Integrate with tRPC, React Query, or SWR cache invalidation
- Auto-unsubscribe when components unmount
- Keep data fresh without manual refresh
How it works
Subscribe where the data lives
Call useYakToolEvent inside any component under YakProvider (or onToolCallComplete on YakClient for non-React apps) and react to the tools you care about by matching event.name.
The assistant runs a tool
When a chat tool call resolves, Yak routes it through your single onToolCall funnel—host functions, tRPC, GraphQL, and REST alike—then fires the completion event with name, args, ok, and result or error.
Your UI refreshes itself
Your handler invalidates the relevant tRPC, React Query, or SWR cache so the affected page re-fetches, and the subscription tears down automatically when the component unmounts.
Frequently asked questions
Related features
Ship ui sync with yak
Add an AI assistant that matches your product—then turn on the features your users need.