Comments Collection
The Comments module provides room-scoped threaded comments with support for replies, emoji reactions, and user tagging. All changes are synced in real time to other participants. Access it viaclient.comments.
Methods
Add Comment
add(text, opts?)
Add a top-level comment to the room. Optionally tag users at creation:
comment is a CollabKitCommentInstance with methods for replies, reactions, and tags.
Get Comments
getAll()
Fetch all comments in the room:
Sync Comments
sync()
Force a full sync of comments from the server:
Delete Comment
delete(commentId)
Delete a top-level comment. This cascades and removes all its replies:
Events
Listen for comment changes across the room:| Event | Payload | Description |
|---|---|---|
add | CollabKitCommentInstance | A new comment was added by another client |
delete | string (comment ID) | A comment was deleted by another client |
update | CollabKitCommentInstance | A comment was updated (reaction, tag, or reply changed) |
Comment Instance
Each comment returned byadd() or getAll() is a CollabKitCommentInstance with its own properties and methods.
Properties
| Property | Type | Description |
|---|---|---|
id | string | Unique comment ID |
text | string | Comment body |
userId | string | ID of the user who created the comment |
parentId | string | null | Parent comment ID (null for top-level) |
reactions | Reaction[] | List of reactions on this comment |
tags | string[] | List of tagged user IDs |
replies | CollabKitCommentInstance[] | Child replies (one level deep) |
createdAt | string | ISO timestamp |
Methods
Reply to Comment
reply(text, opts?)
Add a reply to this comment (one level of nesting):
Delete Reply
deleteReply(replyId)
Remove a reply:
Add Reaction
addReaction(reaction)
Add an emoji reaction to the comment:
Delete Reaction
deleteReaction(reaction)
Remove a reaction:
Add Tag
addTag(userId)
Tag a user on this comment:
Delete Tag
deleteTag(userId)
Remove a user tag:
Tagged users receive a
commentTagged event on their user instance. See User Events.