Skip to main content

Overview

useFetchUserSpaces returns a callable function that fetches all spaces where the authenticated user has an active membership. The response includes membership metadata alongside each space.

Usage Example

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

function MySpaces() {
  const fetchUserSpaces = useFetchUserSpaces();

  const loadSpaces = async () => {
    const result = await fetchUserSpaces({ page: 1, limit: 20 });
    // result.data: UserSpaceItem[]
    result.data.forEach(({ space, membership }) => {
      console.log(space.name, membership.role, membership.status);
    });
  };
}

Parameters

page
number
Page number. Defaults to 1.
limit
number
Number of results per page.

Returns

data
UserSpaceItem[]
Each item contains a space (Space) and a membership object with membershipId, role, status, and joinedAt.
pagination
object
Standard pagination metadata.