Skip to main content

Overview

useCreateComment returns a function that creates a new comment. Use it directly for low-level comment creation. Inside a CommentSectionProvider, prefer createComment from useCommentSection — it adds optimistic UI and manages the comment tree automatically.
Requires an authenticated user.

Usage Example

Parameters

string
required
The entity to comment on.
string
Text content of the comment. Required if gif is not provided.
GifData
GIF attachment. Required if content is not provided.
string
ID of the parent comment for replies.
string
Your own ID to associate with this comment.
string
ID of a comment being referenced/quoted in this comment.
Mention[]
Users or spaces mentioned in the comment content.
Record<string, any>[]
Arbitrary attachment metadata.
Record<string, any>
Arbitrary project-specific data.

Returns

Comment
The newly created comment. See Comment data model.
When the server refuses the comment, the call rejects with its error — among them 403 comment/parent-deleted and 403 comment/parent-removed for a reply to a deleted or removed comment, 403 comment/referenced-deleted and 403 comment/referenced-removed for a quote of one, and 409 comment/foreign-id-taken for a foreignId already in use. See Create Comment → Error Responses for the full list.