Skip to main content

Overview

useFetchCommentsByUserId returns a function that fetches one page of a user’s comments (GET /users/:userId/comments) — top-level comments and replies alike, across entities, cursor-paginated. For a stateful list with “load more”, use useFetchCommentsByUserIdWrapper. What the list contains:
  • Deleted comments are left out. Moderator-removed comments are left out of other people’s history, and included in full (marked moderationStatus: "removed") in the signed-in user’s own.
  • Comments by users the signed-in user is block-edged with are left out by default (blockedFilter).
  • Comments on an entity whose author has blocked the signed-in user are left out — except their own, which stay visible so they can be found and deleted. On those, entity and parentComment are null when requested, and replying, reacting and editing are refused.
  • include never changes which comments are returned. entity is null when 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.

Usage Example

Parameters

string
required
The user whose comments to fetch.
string | null
Only comments on this entity.
string | null
Only comments on entities with this sourceId.
"exclude" | "include-outbound-blocked" | null
Server default "exclude": comments by block-edged users are left out. "include-outbound-blocked" re-includes comments by users the signed-in user blocked, marked isAuthorBlocked: true.
number
Comments per page. 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".
"asc" | "desc"
Applies to every sort. Server default "desc".
ReactionType
With sortBy: "top" only. Server default "upvote".
CommentIncludeParam
Related data to populate: "user", "entity", "space", "parent", "grants".

Returns

A Promise<CursorPaginatedResponse<Comment>>:
Comment[]
The user’s comments for this page. See Comment.
string | null
Pass as cursor to get the next page. null when there’s nothing more.
boolean
Whether more comments exist after this page.