Skip to main content
Create a text comment by passing a reference target and text body to the comment repository. To create a reply, pass the parent comment ID with the same reference target.

Parameters

The current Flutter public comment creation builder exposes metadata(...) and mentionUsers(...), but it does not expose a links(...) method.

Create a Text Comment

Create a top-level text comment with the reference target and text body.
Comment creation is local-first on TypeScript, iOS, Android, and React Native: the SDK persists a local comment before the server confirms it. See Local-First Comment Creation for the per-platform sync states and failure handling.

Reply to a Comment

Replies use the same creation API with parentId set to the comment being replied to.
TypeScript, iOS, and Android accept a links payload when creating a comment, which stores the links found in the comment text alongside the comment. Comments highlight link text; they do not render link preview cards. Build each link with renderPreview: false and leave the preview metadata fields unset — a comment never needs a preview metadata lookup. Each link carries:
Sending links is optional. Clients detect URLs in the comment text and highlight them on their own, so a comment created without a links payload still renders highlighted links. When you do send the payload, include index and length for every link. On Android, AmityLink has no default arguments — pass null for every field you are not setting.
When editing a comment on iOS, links follows update semantics: pass nil to leave the existing links unchanged, or [] to remove them all. See Edit Comment.

Local-First Comment Creation

On TypeScript, iOS, Android, and React Native, the SDK writes the comment to its local store and starts the server request immediately, so an active comment collection can render it before the round trip completes. Flutter waits for the server response instead. The state is observable on every local-first platform, but the names and failure behavior differ: Render local-first comments in a pending style, and handle each platform’s failure state so a failed comment is not mistaken for a server-created one.
On TypeScript and React Native, local-first creation requires the client cache. When the cache is disabled no local comment is created, and the call behaves like a plain server request.
The creation call also rejects when the server request fails; it does not only set the failure state. Catch the error from the creation call and watch sync state through the live collection or observable query. Handling only one of the two leaves either an unhandled rejection or a pending comment that never resolves.

Notes

  • Keep the same referenceId and referenceType as the thread you are replying in.
  • Use query APIs or live collections to display creation and sync state in the UI.
  • Validate your product’s text limits and moderation rules before calling the SDK.
  • Build mention payloads from the user IDs your mention picker returns.

Image Comment

Create comments with uploaded image attachments.

Query Comments

Query top-level comments and reply threads.