useWidget(). See Build widgets first if you still need the server and widget setup.
Call tools from a widget
UseuseCallTool() when a button or form should call another MCP tool. The hook gives you loading, success, and error state.
useCallTool() for user-facing actions. Use useWidget().callTool only for small one-off calls where you do not need hook-managed state.
Save widget state
UsesetState for UI state that should survive re-renders and be available to future model turns.
Send a follow-up message
UsesendFollowUpMessage when a widget action should ask the model to continue the conversation.
Request display modes
UserequestDisplayMode when a widget needs more room.
displayMode for the actual current mode.
Combine actions carefully
A single click should usually do one main thing. For example:- call a tool to fetch more data
- update widget state after a user choice
- send a follow-up message for model reasoning
- request fullscreen for a larger view
Next steps
- Use Model context to decide what the model should know about these interactions.
- Use
useCallTool()for full call state and typing details. - Use
useWidget()for all host actions and display-mode behavior.