> ## 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]
>
> If the comment author is block-edged with the signed-in caller, in either
> direction, this returns `404` with `comment/not-found` — identical to a
> comment that does not exist. An embedded `parentComment` is nulled under the
> same rule. Requires the `moderation` bundle.

## 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

**foreignId** `string` *required*

The foreign ID to look up.

**include** `string | string[]`

Populate related data. Accepted values: `"user"`, `"entity"`, `"space"`, `"parent"`, `"grants"`.

## Returns

**comment** `Comment`

The fetched comment. See [Comment data model](https://docs.sublay.io/v7/data-models/comment.md).


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