Skip to main content

Overview

Returns an async function that sends a message to a conversation. An optimistic entry is inserted into Redux immediately — with a temporary ID — and replaced by the server-confirmed message on success. If the request fails, the optimistic message is flagged with sendFailed: true.
Requires ChatProvider in the component tree.

Usage Example

Props

string
required
The ID of the conversation to send the message to.

Parameters

The hook returns a function. That function accepts:
string
Plain text content of the message.
GifData | null
GIF attachment data. null sends no GIF.
Mention[]
User mentions to embed in the message.
Record<string, any>
Arbitrary key-value data attached to the message.
string
ID of the message being quoted. Populates quotedMessage on the server-confirmed message.
string
ID of the parent message when sending a thread reply.
{ files: UploadFileInput[]; options: UploadImageOptions }
Images on the message, processed into sizes per options (mode is required); each comes back with image and its variants. Each file is a File or Blob, or a React Native file { uri, name, type? }. A request takes at most 20 files in all. When provided, the request is sent as multipart/form-data. Requires the files-images bundle.
{ files: UploadFileInput[]; options?: { pathParts?: string[] } }
Files on the message, stored as uploaded (image is null, an image sent here included). When provided, the request is sent as multipart/form-data. Requires the files-images bundle.

Returns

SentChatMessage & { localId?: string }
The server-confirmed ChatMessage, without reactionCounts, userReactions and grants (a new message has none), and with localId echoed back. When spaceReputation is requested, its embedded sender carries an added spaceReputation number. See Reputation.

Notes

  • A message needs at least one of content, gif, images or files; otherwise the server refuses it with 400 chat/empty-message.
  • For integration guidance, see Chat: Messages.