Skip to main content

Overview

useFetchMySpaces returns a callable function that fetches the spaces where the authenticated user has a membership (active by default). The response includes membership metadata alongside each space. Every space the user is an active member of is listed, whatever its visibility, so this is the hook for a “my spaces” screen (a pending, banned or rejected membership of a space the user can’t see is left out); useFetchManySpaces lists public spaces only. It can search within the user’s spaces and sort them.

Usage Example

Parameters

string
Membership status to list: "active" (default), "pending", or "banned". Use "pending" to show join requests still awaiting approval.
number
Page number. Defaults to 1.
number
Number of results per page.
SpaceMemberRole | SpaceMemberRole[]
Only memberships with this role: "admin", "moderator" or "member", or an array of them.
boolean
true returns every matching membership without pagination; the response then has no pagination.
string | null
Free-text search term, matched as a case-insensitive substring. A blank value is left out of the request, and searchFields with it.
"slug" | "name" | "description" | null
The one field query is matched against. Leave it out to match the slug, the name or the description.
string
Sort order: "joinedAt" (when the user joined), "createdAt" (when the space was created), "alphabetical" (by name) or "members" (by active member count). Defaults to "joinedAt".
string
Direction, "asc" or "desc", for any sortBy. Left out: A–Z for "alphabetical", otherwise newest / most first.
string | "none" | "any" | null
Narrows the list by where each space sits in the tree. "none": the user’s memberships in top-level spaces only. A space id: their memberships in that space’s direct sub-spaces. "any", left out or null: memberships at every level (the default). null is left out of the request, never sent as "none".A membership in a sub-space whose parent the user isn’t a member of is not top-level, so "none" leaves it out.
SpaceIncludeParam
Optional. A single value or an array; the only value is "files". Pass it to populate avatar and banner file objects on each space.

Returns

MySpaceItem[]
Each item contains a space (Space) and a membership object with membershipId, role, status, and joinedAt.
object
Standard pagination metadata.
See also: Fetch My Spaces