Function: useMastraThreads()
useMastraThreads(
agentId?,enabled?):object
Fetch (and re-fetch) the caller’s conversation threads for an agent
via client.threads(agentId). Drives the conversation list / sidebar
so the user can switch between the threads they own. Newest first
(updatedAt DESC), scoped server-side to the caller’s resource.
Returns a refresh() the chat driver calls after a turn completes
(a new thread appears, or its auto-generated title lands) and after a
clear / delete, so the list stays in sync without polling. Pass
enabled: false to skip the fetch entirely (e.g. when the sidebar is
hidden), in which case threads stays empty. A failed fetch degrades
to an empty list - the conversation list is a non-critical
enhancement layered over the always-available default thread.
Parameters
Section titled “Parameters”agentId?
Section titled “agentId?”string
enabled?
Section titled “enabled?”boolean = true
Returns
Section titled “Returns”object
error:
Error|null
loading
Section titled “loading”loading:
boolean
refresh
Section titled “refresh”refresh: () =>
void
Returns
Section titled “Returns”void
threads
Section titled “threads”threads:
object[]