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

# Fetch mutual workspaces

> Fetch the workspaces the current user and another user have in common

## Overview

`useFetchMutualWorkspaces` returns a callable that fetches one page of the workspaces both the current user and another user are in — their workspaces in common. The actor is derived from the bearer token — no `actingUserId` is sent. Each row's `reasons` is the **current user's** standing on it.

## Usage Example

```tsx theme={null}
import { useFetchMutualWorkspaces } from "@sublay/react-js";

function SharedWorkspaces({ otherUserId }: { otherUserId: string }) {
  const fetchMutualWorkspaces = useFetchMutualWorkspaces();

  const load = async () => {
    const { data } = await fetchMutualWorkspaces({
      userId: otherUserId,
      relation: "direct", // workspaces you're both owners or members of
      limit: 20,
    });
    data.forEach((workspace) => console.log(workspace.name, workspace.reasons));
  };
}
```

## Parameters

**userId** `string` *required*

The other user's ID. An ID that matches no user returns an empty page; your own ID returns your own workspaces.

**relation** `"reachable" | "direct" | null`

`"reachable"` (the default): workspaces each of you can open, by any reason. `"direct"`: workspaces each of you owns or has a member row on. `null` is left out of the request.

**sortDir** `"desc" | "asc" | null`

Order by creation time: `"desc"` (the default) newest first, `"asc"` oldest first. `null` is left out of the request.

**page** `number`

Page number. Defaults to `1`.

**limit** `number`

Results per page. Defaults to `20`.

**include** `WorkspaceIncludeParam`

A single value or an array. The only value is `"memberCount"`: it adds each row's **direct** member count.

## Returns

Returns a `PaginatedResponse<Workspace>` (`{ data, pagination }`).

## Related

* [Fetch Mutual Workspaces API](https://docs.sublay.io/v8/api-reference/workspaces/fetch-mutual-workspaces.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.