> ## Documentation Index
> Fetch the complete documentation index at: https://docs.replyke.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Fetch many spaces

> Fetch a paginated list of spaces with filtering and sorting

## 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`](/hooks/space-lists/use-space-list) instead.

## Usage Example

```tsx theme={null}
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

<ParamField path="page" type="number">
  Page number to fetch. Defaults to `1`.
</ParamField>

<ParamField path="limit" type="number">
  Number of results per page.
</ParamField>

<ParamField path="sortBy" type="string">
  Sort order: `"newest"`, `"oldest"`, `"most_members"`, or `"least_members"`.
</ParamField>

<ParamField path="searchSlug" type="string | null">
  Filter spaces whose slug contains this value.
</ParamField>

<ParamField path="searchName" type="string | null">
  Filter spaces whose name contains this value.
</ParamField>

<ParamField path="searchDescription" type="string | null">
  Filter spaces whose description contains this value.
</ParamField>

<ParamField path="searchAny" type="string | null">
  Search across name, slug, and description simultaneously.
</ParamField>

<ParamField path="memberOf" type="boolean">
  When `true`, returns only spaces where the current user is an active member.
</ParamField>

<ParamField path="parentSpaceId" type="string | null">
  Filter to child spaces of a specific parent. Pass `null` for root-level spaces only.
</ParamField>

<ParamField path="include" type="&#x22;files&#x22; | string[]">
  Optional. Pass `"files"` to include avatar file objects in each result.
</ParamField>

## Returns

<ResponseField name="data" type="Space[]">
  Array of [Space](/data-models/space) objects.
</ResponseField>

<ResponseField name="pagination" type="object">
  Pagination metadata including `page`, `limit`, `total`, and `hasMore`.
</ResponseField>
