Overview
useEntityComments is a lower-level hook that fetches and manages a paginated comment tree for a given entity ID. It is used internally by CommentSectionProvider. Use it directly when you need comment tree management without the full provider.
For most use cases, use
CommentSectionProvider + useCommentSection instead. See Comment Section.Usage Example
Props
The entity ID to fetch comments for.
Comments per page. Default:
10.Initial sort:
"createdAt", "top", or "controversial". Default: "createdAt". "new"/"old" are deprecated aliases for "createdAt" (removed in v8).Initial sort direction for
sortBy: "createdAt". Default: "desc" (newest first).Populate related data. Accepted values:
"user", "entity", "space", "parent".Return Values
Flat map of all comments and their replies, keyed by comment ID.
Paginated root-level comments (not newly added ones).
Newly added root comments from this session, sorted newest-first.
true during fetches.true when more pages are available.Current sort order.
Changes sort order and resets to page 1.
Current sort direction for
sortBy: "createdAt".Changes sort direction and resets to page 1.
Loads the next page.
Inserts comments into the tree. Pass
newlyAdded: true for freshly submitted comments.Removes a comment from the tree.
Marks a comment as deleted (Reddit-style placeholder) without removing it from the tree.

