Skip to main content

Overview

useFetchManyComments returns a function that fetches one level of a comment thread (GET /comments): an entity’s top-level comments (entityId) or a comment’s direct replies (parentId). It’s the fetch function behind useEntityComments and useReplies. Use it directly when you need full control over a thread request. For a user’s comments across entities, use useFetchCommentsByUserId.

Usage Example

Parameters

One of entityId or parentId is required.
string
Fetch this entity’s top-level comments.
string
Fetch this comment’s direct replies.
number
How many comments at the level being fetched. Server default 10, max 100.
string | null
pagination.nextCursor from the previous response. Omit for the first page. Send the same sort as the request that returned it.
CommentsSortByOptions
"createdAt", "top" (raw count of sortByReaction) or "controversial". Server default "createdAt". "new" / "old" are deprecated aliases for "createdAt".
"asc" | "desc"
Applies to every sort. Server default "desc".
ReactionType
With sortBy: "top" only: the reaction to rank by. Server default "upvote".
number
Levels of replies to nest under each returned comment (0–5). Server default 0.
number
Replies per comment in the nested levels (at least 1). Server default 3.
CommentReplySortByOptions
Sort for the nested levels: "createdAt", "top" or "controversial". Defaults to sortBy.
"asc" | "desc"
Sort direction for the nested levels. Defaults to sortDir.
ReactionType
The reaction the nested levels rank by, when their sort is "top".
"user" | "grants" | ("user" | "grants")[]
Related data to populate, at every level.
A request can return at most 500 comments, nested replies included — see Request size limit.

Returns

A Promise<CursorPaginatedResponse<Comment>>:
Comment[]
The comments at the requested level. With replyDepth above 0, each carries nested replies ({ data, pagination }). When spaceReputation is requested, each embedded author carries an added spaceReputation number. See Reputation.
string | null
Pass as cursor to get the next page. null when there’s nothing more.
boolean
Whether more comments exist after this page.
See Fetch Many Comments for placeholders, block flags and how to continue nested replies.