Skip to main content
The useSpaceList hook provides a Redux-backed, paginated list of spaces with support for filtering, sorting, and search. It lists the space directory, for discovery and browse pages. For the spaces the current user is a member of, see My spaces below. Spaces in a list carry no memberPermissions; to show what the current user may do in one, load it with SpaceProvider or useFetchSpace.

Basic Usage

Filtering and Sorting

A space list shows top-level spaces by default: it sends parentSpaceId: "none" on every page, including loadMore and a re-sort, until you name a parent or "any".

Sort Options

Pass sortDir: "asc" or "desc" to reverse any of them, for example fetchSpaces({ filters: { sortBy: "createdAt", sortDir: "asc" } }) for oldest first. Left out, each sort uses the direction above.

Creating and Deleting from a List

useSpaceList also exposes create and delete operations that automatically update the list state:

Multiple Independent Lists

Each useSpaceList call uses a listId to maintain independent Redux state. You can have multiple lists on the same page without interference:

My Spaces

Across levels (parentSpaceId "none" or "any"), a space list includes a space only if it and every space above it are public. Under one parent (a space id), it includes the sub-spaces the user can see that are public or that they’re an active member of — the same ones the parent’s childSpaces preview shows and its childSpacesCount counts. For a “my spaces” screen, use useFetchMySpaces: it lists the spaces the current user is a member of, whatever their visibility, with their membership on each, and takes its own query, searchFields, sortBy ("joinedAt", the default, "createdAt", "members" or "alphabetical") and sortDir. It also takes parentSpaceId: "none" for the user’s memberships in top-level spaces only, or a space id for their memberships in that space’s direct sub-spaces. "any", left out or null: memberships at every level (the default, because membership is per space). "none" goes by where the space sits, not by what the user belongs to: a membership in a sub-space whose parent the user isn’t in is not top-level, so "none" leaves it out.

Return Values

Space[]
The current page of loaded spaces.
boolean
true while fetching.
SublayError | null
The last load failure, or null. Cleared when the next load starts; loadMore() retries it. A SublayError.
boolean
true while loadMore() has something to fetch: a next page, or a load that failed.
({ filters?, config?, options? }) => void
Trigger a new fetch with the given filters and configuration, as one object. Resets to page 1.
() => Promise<void>
Fetch the next page of results and append it, or retry the load that failed. Never rejects: a failure lands in error.
() => Promise<void>
Reload page 1 with the list’s stored filters, sort and config. The loaded spaces stay until the new first page replaces them. Never rejects.
function
Create a new space and insert it into the list.
function
Delete a space and remove it from the list.

Hook Reference