Loading Messages
useChatMessages fetches paginated messages for a conversation. Messages are stored in Redux and kept in sync by the ChatProvider socket.
loadOlder fetches messages older than the oldest currently loaded.
To include attached files in the response, pass includeFiles: true:
useChatMessages.
Sending Messages
useSendMessage returns an async function that sends a message and performs an optimistic insert — the message appears immediately in the UI with a temporary ID, then the temporary entry is replaced by the server-confirmed message.
Message Content Options
useSendMessage accepts a rich set of parameters:
| Parameter | Type | Description |
|---|---|---|
content | string | Plain text content |
gif | GifData | GIF attachment |
mentions | Mention[] | User mentions embedded in the message |
metadata | Record<string, any> | Arbitrary key-value data |
quotedMessageId | string | null | ID of the message being quoted/replied to |
parentMessageId | string | null | ID of the parent message (for thread replies) |
files | File[] | File attachments (triggers multipart upload) |
Sending with Files
Whenfiles is provided, the hook automatically switches to a multipart form upload:
useSendMessage.
Editing Messages
useEditMessage returns a function that takes conversationId, messageId, and updated content fields. The Redux store is updated immediately on success.
useEditMessage.
Deleting Messages
useDeleteMessage performs a soft delete. The message is removed from the local Redux store immediately; on the server, it is soft-deleted (content cleared, userDeletedAt set).
useDeleteMessage.
Reactions
useToggleReaction adds or removes an emoji reaction on a message. The response includes updated reactionCounts and userReactions:
useToggleReaction.
Next Steps
Real-time
Typing indicators, unread counts, and read receipts
Threads
Threaded replies on messages

