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. That createComment sends text, a GIF and mentions only: to upload images or files with a comment, use useCreateComment. With images or files, the request is sent as multipart.
Requires an authenticated user.

Usage Example

Parameters

string
required
The entity to comment on.
string | null
Text content of the comment. A comment needs at least one of content, gif, attachments, images or files; the call throws before sending when all of them are empty.
GifData | null
GIF attachment.
string | null
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.
{ files: UploadFileInput[]; options: UploadImageOptions }
Images on the comment, processed into sizes per options (mode is required). Each file is a File or Blob, or a React Native file { uri, name, type? }. A request takes at most 20 files in all. Sends multipart. Requires the files-images bundle.
{ files: UploadFileInput[]; options?: { pathParts?: string[] } }
Files on the comment, stored as uploaded. Each file’s type comes from its MIME type; an image sent here isn’t processed, so it has no image data. Sends multipart. Requires the files-images bundle.
A comment’s files are set when it is created: editing changes its text only, and deleting it deletes its files.

Returns

Comment
The newly created comment. With the files-images bundle installed it carries files ([] for none). 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.