Skip to main content

Overview

useFetchManySpaces returns a callable function for fetching multiple spaces. It supports searching by name, slug, description, or a combined query; filtering by membership or parent space; and sorting. For paginated, stateful lists with load-more support, use useSpaceList instead.

Usage Example

import { useFetchManySpaces } from "@replyke/react-js";

function SpaceSearch() {
  const fetchSpaces = useFetchManySpaces();

  const handleSearch = async (query: string) => {
    const result = await fetchSpaces({ searchAny: query, sortBy: "newest" });
    console.log(result.data, result.pagination);
  };
}

Parameters

page
number
Page number to fetch. Defaults to 1.
limit
number
Number of results per page.
sortBy
string
Sort order: "newest", "oldest", "most_members", or "least_members".
searchSlug
string | null
Filter spaces whose slug contains this value.
searchName
string | null
Filter spaces whose name contains this value.
searchDescription
string | null
Filter spaces whose description contains this value.
searchAny
string | null
Search across name, slug, and description simultaneously.
memberOf
boolean
When true, returns only spaces where the current user is an active member.
parentSpaceId
string | null
Filter to child spaces of a specific parent. Pass null for root-level spaces only.
include
"files" | string[]
Optional. Pass "files" to include avatar file objects in each result.

Returns

data
Space[]
Array of Space objects.
pagination
object
Pagination metadata including page, limit, total, and hasMore.