Skip to main content

Overview

useSpaceList provides a stateful, paginated list of public spaces (the space directory) with support for filtering, sorting, search, and creation. For the spaces the current user is a member of, whatever their visibility, use useFetchMySpaces. Each list is identified by a listId and maintains independent Redux state, allowing multiple lists on the same page. Spaces in a list carry no memberPermissions; to show what the current user may do in one, load it with SpaceProvider or useFetchSpace. For full integration guidance, see Space Lists.

Usage Example

Parameters

string
required
Unique identifier for this list’s Redux state slice. Use distinct IDs for independent lists.

Returns

Space[]
Currently loaded spaces.
boolean
true while fetching.
SublayError | null
The last load failure, or null. Cleared when the next load starts; loadMore() retries it. Shared by every mounted hook on the same listId. 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. Resets to page 1. Takes one object: filters merge into the list’s current filters, config is the list’s page size, and options control this fetch.
() => Promise<void>
Load the next page of spaces and append it, or retry the load that failed (a failed first page is retried as the first page). Does nothing before the first fetchSpaces, while a load is running on this list, while a debounced filter change is waiting to be fetched, or when there is nothing more. Never rejects: a failure lands in error.
() => Promise<void>
Reload page 1 with the list’s stored filters, sort and config; a debounced filter change still waiting runs now instead. The loaded spaces stay until the new first page replaces them. Does nothing before the first fetchSpaces. Never rejects: a failure lands in error.
function
Create a new space and insert it into the list. name is required (3–100 characters after trimming); every other field is optional, and null is the same as leaving it out. Resolves with the created space plus memberPermissions (see SpaceMemberPermissions), or undefined if the request failed.
Space avatars and banners are uploaded as files, not URLs, so they can’t be set through this hook. Use useCreateSpace or useUpdateSpace, which send the image as multipart/form-data.
function
Delete a space and remove it from the list.
string | null
Current sort setting from Redux state. The list sorts by "createdAt" (newest first) until you pass another sortBy.
"asc" | "desc" | null
Current sort direction. null means the sort’s natural direction: A–Z for "alphabetical", otherwise newest / most first.
string | null
Current search term from Redux state.
"slug" | "name" | "description" | null
The field the current search term is matched against. null matches the slug, the name or the description.
string | "none" | "any"
The parent filter in use: a space id (its direct sub-spaces the user can see that are public or that they’re an active member of), "none" (top-level spaces only, the default) or "any" (spaces at every level). Every page, including loadMore and a re-sort, is fetched with it.