> ## Documentation Index
> Fetch the complete documentation index at: https://replyke-feat-push-rich-payload-fields.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Fetch entity

> Fetch a single entity by its Sublay entity ID

## Overview

`useFetchEntity` returns a function that fetches a single entity by its Sublay entity ID. Use this for on-demand fetches outside of `EntityProvider`.

## Usage Example

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

function EntityLoader({ entityId }: { entityId: string }) {
  const fetchEntity = useFetchEntity();

  const load = async () => {
    const entity = await fetchEntity({ entityId, include: ["user", "topComment"] });
    console.log(entity);
  };

  return <button onClick={load}>Load Entity</button>;
}
```

## Parameters

<ParamField path="entityId" type="string" required>
  The Sublay entity ID to fetch.
</ParamField>

<ParamField path="include" type="string | string[]">
  Optional. Populate related fields. Accepted values: `"user"`, `"space"`, `"topComment"`, `"saved"`, `"files"`.
</ParamField>

<ParamField path="spaceReputationId" type="string">
  Optional. Resolves the embedded author's reputation into a `spaceReputation` number. Accepts a space `<uuid>`, `"none"` (project-general bucket), or `"context"` (server-derived from the request context). Empty string, `"general"`, and `null` are rejected. See [Reputation](/data-models/reputation).
</ParamField>

<ParamField path="spaceReputationDescendants" type="boolean">
  Optional. When `true`, `spaceReputation` is the subtree sum (the space plus all its descendants). Only honored when `spaceReputationId` is an explicit `<uuid>`.
</ParamField>

## Returns

<ResponseField name="Entity" type="Entity">
  The fetched entity. When `spaceReputationId` is set, the embedded author carries an added `spaceReputation` number. See [Entity data model](/data-models/entity) and [Reputation](/data-models/reputation).
</ResponseField>
