> ## 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 followers by user ID

> Fetch the followers of any user by their ID

export const SpaceReputationParams = ({variant = "context", field = "path"}) => {
  const isUser = variant === "user";
  return <>
      <ParamField {...{
    [field]: "spaceReputation",
    type: "object"
  }}>
        Opt-in. Adds a <code>spaceReputation</code> number to each returned user,
        scoped to a single space. Requires the <code>reputation</code> bundle.
        The <code>reputation</code> total is always present regardless;{" "}
        <code>spaceReputation</code> is purely additive and only appears when you
        pass this object. <strong>This object is the primary form</strong> — it
        replaces the deprecated flat props below. See the{" "}
        <a href="/v8/data-models/reputation">Reputation data model</a> for the
        full contract.

        <Expandable title="spaceReputation">
          {isUser ? <ParamField name="spaceId" type="string | &quot;none&quot;" required>
              Which bucket to read. A space <strong><code>&lt;uuid&gt;</code></strong> reads that
              space's bucket; <strong><code>"none"</code></strong> reads the
              project-general (space-less) bucket.{" "}
              <strong><code>"context"</code> is rejected (400)</strong> on this
              endpoint — there is no space context to derive. The empty string
              and the legacy <code>general</code> / <code>null</code> aliases are
              also rejected. Missing buckets read as <code>0</code>.
            </ParamField> : <ParamField name="spaceId" type="string | &quot;none&quot; | &quot;context&quot;" required>
              Which bucket to read. One of: a space <strong><code>&lt;uuid&gt;</code></strong>{" "}
              (that space's bucket), <strong><code>"none"</code></strong> (the
              project-general, space-less bucket), or{" "}
              <strong><code>"context"</code></strong> (the space derived from the
              request context — resolved per-row on lists, or the single space on
              member/team/conversation surfaces). The empty string and the legacy{" "}
              <code>general</code> / <code>null</code> aliases are rejected (400).
              Missing buckets read as <code>0</code>.
            </ParamField>}
          <ParamField name="includeDescendants" type="boolean">
            Only honored when <code>spaceId</code> is an explicit space <code>&lt;uuid&gt;</code>.
            When <code>true</code>, <code>spaceReputation</code> is the{" "}
            <strong>subtree sum</strong> — the named space plus all of its
            descendant spaces (the root space's own bucket included). Ignored for{" "}
            <code>"none"</code>; not allowed with <code>"context"</code>.
          </ParamField>
        </Expandable>
      </ParamField>

      {isUser ? <ParamField {...{
    [field]: "spaceReputationId",
    type: "string",
    deprecated: true
  }}>
          <strong>Deprecated</strong> — use the <code>spaceReputation</code>{" "}
          object instead. The flat form of <code>spaceReputation.spaceId</code>.
          Still accepted (the object wins if both are passed); removal is a later
          major version. Accepts a space <code>&lt;uuid&gt;</code> or <code>"none"</code> only —{" "}
          <code>"context"</code> is rejected (400) on this endpoint.
        </ParamField> : <ParamField {...{
    [field]: "spaceReputationId",
    type: "string",
    deprecated: true
  }}>
          <strong>Deprecated</strong> — use the <code>spaceReputation</code>{" "}
          object instead. The flat form of <code>spaceReputation.spaceId</code>.
          Still accepted (the object wins if both are passed); removal is a later
          major version. Accepts a space <code>&lt;uuid&gt;</code>, <code>"none"</code>, or{" "}
          <code>"context"</code>.
        </ParamField>}

      <ParamField {...{
    [field]: "spaceReputationDescendants",
    type: "boolean",
    deprecated: true
  }}>
        <strong>Deprecated</strong> — use{" "}
        <code>spaceReputation.includeDescendants</code> instead. The flat form,
        only honored alongside an explicit <code>spaceReputationId</code> <code>&lt;uuid&gt;</code>.
      </ParamField>
    </>;
};

## Overview

Returns a function that fetches the paginated list of followers for any user, identified by `userId`. Authentication is optional — the endpoint works without a token. When the caller is signed in, any user with a block between them and the caller, in either direction, is excluded from the results. Block filtering requires the `moderation` bundle.

For fetching your own followers, see `useFetchFollowers`.

## Usage Example

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

function UserFollowers({ userId }: { userId: string }) {
  const fetchFollowersByUserId = useFetchFollowersByUserId();
  const [followers, setFollowers] = useState([]);

  useEffect(() => {
    fetchFollowersByUserId({ userId, page: 1 }).then((res) => {
      setFollowers(res.data);
    });
  }, [userId]);

  return (
    <ul>
      {followers.map(({ followId, user }) => (
        <li key={followId}>{user.name}</li>
      ))}
    </ul>
  );
}
```

## Parameters

The hook returns a function. That function accepts:

<ParamField path="userId" type="string" required>
  The ID of the user whose followers to fetch.
</ParamField>

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

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

<ParamField path="query" type="string">
  Optional search term. Filters the list to users whose username or name contains this text (case-insensitive). When omitted, no filtering is applied.
</ParamField>

<ParamField path="searchFields" type="string">
  Restricts which field `query` matches against — `username` or `name`. When omitted, `query` matches either field.
</ParamField>

<SpaceReputationParams variant="user" field="path" />

## Returns

Returns a `PaginatedResponse` containing an array of follower entries:

<ResponseField name="data" type="FollowerWithFollowInfo[]">
  Array of follower entries.

  <Expandable title="FollowerWithFollowInfo properties">
    <ResponseField name="followId" type="string">
      ID of the follow record.
    </ResponseField>

    <ResponseField name="user" type="User">
      The follower's user profile. When `spaceReputation` is requested, it carries an added `spaceReputation` number. See [User data model](/v8/data-models/user) and [Reputation](/v8/data-models/reputation).
    </ResponseField>

    <ResponseField name="followedAt" type="string">
      ISO timestamp of when the follow was created.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="pagination" type="object">
  Pagination metadata including `currentPage`, `totalPages`, `totalCount`, `hasNextPage`, and `hasPreviousPage`.
</ResponseField>

## Related

* [useFetchFollowers](/v8/hooks/follows/use-fetch-followers) — fetch the current user's own followers
* [useFetchFollowersCountByUserId](/v8/hooks/follows/use-fetch-followers-count-by-user-id) — get follower count for a user


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