> ## 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 comment by foreign ID

> Fetch a single comment by its foreign ID

## Overview

`useFetchCommentByForeignId` returns a function that fetches a comment using the foreign ID from your own system. Useful when you've stored your own identifier on a comment and need to retrieve it later.

<Note>
  With the `moderation` bundle installed, the comment comes back the way a thread shows it: in full with `isAuthorBlocked: true` when the signed-in user blocked its author, or as a [placeholder](/v8/data-models/comment#placeholders) with `isUnavailable: true` when the author blocked them. An embedded `parentComment` follows the same rules.

  When the **entity's** author has blocked the signed-in user, the request fails with `404 comment/not-found`, identical to a comment that doesn't exist — except for the user's own comments, which still load (with `entity` and `parentComment` set to `null` when requested) so they can be found and deleted. Replying to, reacting to and editing those are refused. `entity: null` only means the entity isn't available to the signed-in user (for example, removed by a moderator) — the comment is still returned, and `null` doesn't say why.
</Note>

## Usage Example

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

function MyComment({ myCommentId }: { myCommentId: string }) {
  const fetchComment = useFetchCommentByForeignId();

  const load = async () => {
    const comment = await fetchComment({ foreignId: myCommentId });
    console.log(comment);
  };

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

## Parameters

<ParamField path="foreignId" type="string" required>
  The foreign ID to look up.
</ParamField>

<ParamField path="include" type="string | string[]">
  Populate related data. Accepted values: `"user"`, `"entity"`, `"space"`, `"parent"`, `"grants"`.
</ParamField>

## Returns

<ResponseField name="Comment" type="Comment">
  The fetched comment. See [Comment data model](/v8/data-models/comment).
</ResponseField>


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