Skip to main content

Overview

useFetchManyWorkspaces returns a callable that fetches one page of the current user’s workspaces: by default every workspace they can open, or with relation: "direct" only the ones they own or are a member of. Each row carries reasons, why the user can open it. The actor is derived from the bearer token — no actingUserId is sent. For a managed paginated list with load-more, use useWorkspaceList.

Usage Example

Parameters

The callable takes an optional params object:
"reachable" | "direct" | null
Which workspaces the list holds. "reachable", left out or null (the default): every workspace the user can open — owned, a member of, under a workspace they own, or reached by a capability held on an ancestor. "direct": only the workspaces they own or have a member row on. null is left out of the request.
"desc" | "asc" | null
Order by creation time. "desc", left out or null (the default): newest first. "asc": oldest first, which puts every parent before its children. null is left out of the request.
number
Page number.
number
Page size: a whole number from 1 to 100. Defaults to 20. A larger value is rejected with 400 workspace/invalid-query, never lowered to 100.
string | "none" | "any" | null
Narrows the list by where each workspace sits in the tree. "none": top-level workspaces only. A workspace id: the workspaces directly under that workspace. "any", left out or null: workspaces at every level (the default). It applies within relation. null is left out of the request.
WorkspaceIncludeParam
A single value or an array. The only value is "memberCount": it adds each row’s direct member count, resolved in one grouped query over the returned page rather than one request per workspace; omit it and the field is absent from each row.

Returns

Returns a PaginatedResponse<Workspace> ({ data, pagination }).