MessagesContext

Best Practices

  • Use this context for message-level UI concerns, not global channel state.
  • Prefer the provided handlers (handleEdit, handleDelete, etc.) to keep behavior consistent.
  • Avoid heavy logic in handlers that can trigger list-wide re-renders.
  • Use removeMessage/updateMessage only for local UI state, not server-side mutations.
  • Keep messageActions and supportedReactions stable (memoized) for performance.

Value

additionalPressableProps

Extra props passed to the underlying Pressable used in message components like MessageContent.

Type
object

channelId

ID of the current channel.

Type
string

deletedMessagesVisibilityType

Controls visibility of deleted messages in the channel.

  • always: Visible to both sender and receiver.
  • never: Visible to no one.
  • sender: Visible only to the sender.
  • receiver: Visible only to the receiver.
TypeDefault
enum('always', 'never', 'receiver', 'sender')'both'

disableTypingIndicator

Disable the typing indicator in MessageList.

TypeDefault
booleanfalse

dismissKeyboardOnMessageTouch

Dismiss the keyboard when the user touches a message in the list.

TypeDefault
booleanfalse

enableMessageGroupingByUser

Note: Available in SDK version >= v3.9.0.

If false, consecutive messages from the same user won’t be grouped.

TypeDefault
booleantrue

enableSwipeToReply

If true, users can swipe to reply to a message.

TypeDefault
Booleantrue

forceAlignMessages

Forces all messages to align left or right. By default, received messages are left and sent messages are right.

TypeDefault
'left' | 'right' | falsefalse

formatDate

Format function for dates in message status and deleted message components.

Type
function
ParameterDescription
datedate to format provided as a string, Date, or number (Unix Timestamp)

handleBan

Called when the Ban User action is triggered. It does not override default behavior. See customize message actions.

Type
function
ParameterDescription
messagemessage the action is called on

handleCopy

Called when the Copy Message action is triggered. It does not override default behavior. See customize message actions.

Type
function
ParameterDescription
messagemessage the action is called on

handleDelete

Called when the Delete Message action is triggered. It does not override default behavior. See customize message actions.

Type
function
ParameterDescription
messagemessage the action is called on

handleDeleteForMe

Called when the Delete Message for me action is triggered. It does not override default behavior. See customize message actions.

Type
function
ParameterDescription
messagemessage the action is called on

handleEdit

Called when the Edit Message action is triggered. It does not override default behavior. See customize message actions.

Type
function
ParameterDescription
messagemessage the action is called on

handleFlag

Called when the Flag Message action is triggered. It does not override default behavior. See customize message actions.

Type
function
ParameterDescription
messagemessage the action is called on

handleMute

Called when the Mute User action is triggered from the message actions list. It does not override default behavior. See customize message actions.

Type
function
ParameterDescription
messagemessage the action is called on

handleQuotedReply

Called when the Reply action is triggered. It does not override default behavior. See customize message actions.

Type
function
ParameterDescription
messagemessage the action is called on

handleReaction

Called when a reaction is selected in the message menu (add or remove). It does not override default behavior. See customize message actions.

Type
Function
ParameterDescription
messageMessage the action is called on.
reactionTypeString designating the type of reaction.

handleRetry

Called when the Retry action is triggered. It does not override default behavior. See customize message actions.

Type
function
ParameterDescription
messagemessage the action is called on

handleThreadReply

Called when the Thread Reply action is triggered. It does not override default behavior. See customize message actions.

Type
function
ParameterDescription
messagemessage the action is called on

initialScrollToFirstUnreadMessage

Load the channel starting at the first unread message.

TypeDefault
booleanfalse

isAttachmentEqual

Returns true if rendering nextAttachment would produce the same result as prevAttachment, otherwise false.

Type
function
ParameterDescription
prevAttachmentprevious message attachment to be compared
nextAttachmentnext message attachment to be compared

legacyImageViewerSwipeBehaviour

markdownRules

Rules for simple-markdown.

Type
object

messageActions

An array of actions, or a function returning an array, shown in the message menu. See customize message actions.

TypeDefault
Array | FunctionmessageActions
ParameterDescription
actionInfoAn object containing the original actions and relevant message data

messageContentOrder

Order for rendering message content.

TypeDefault
array['quoted_reply', 'gallery', 'files', 'text', 'attachments']

myMessageTheme

Theme applied to the current user’s messages.

Type
object

Memoize this object or pass a stable reference.

messageSwipeToReplyHitSlop

Defines the hitSlop area for the message swipe-to-reply gesture.

TypeDefault
Object{ top: number, left: number, bottom: number, right: number }{left: screenWidth, right: screenWidth}

messageTextNumberOfLines

Number of lines for message text in the Message Overlay.

TypeDefault
number5

onLongPressMessage

Called when a user long-presses a message. The default opens the message menu.

Type
function
ParameterDescription
payload{ actionHandlers, message }

onPressInMessage

Called on touch start, before onPressMessage.

Type
function
ParameterDescription
payload{ actionHandlers, message }

onPressMessage

Called when a user presses a message.

The default handler behaves differently for reactions and attachments. Handle those cases if you override it.

Type
function
ParameterDescription
payload{ additionalInfo, actionHandlers, message }

additionalInfo provides extra data for certain emitters (for example, user details for textMention).

For example:

<Channel
      onPressMessage={({ additionalInfo, defaultHandler, emitter }) => {

          if (emitter === 'textMention') {
            console.log(additionalInfo?.user);
            return;
          }

          if (emitter === 'card' || emitter === 'textLink') {
            console.log(additionalInfo?.url);
            return;
          }

          if (emitter === 'fileAttachment') {
            console.log(additionalInfo?.attachment);
            return;
          }

          defaultHandler?.();
      }}
    >

additionalInfo may change as we add more emitter use cases.

reactionListPosition

Position of the reaction list in the message component. Default is above the message content.

TypeDefault value
top | bottom'top'

removeMessage

Remove a message from local state only (does not call channel.deleteMessage).

Type
(message) => void

Reply

Renders a preview of the parent message for quoted replies.

TypeDefault
ComponentTypeReply

retrySendMessage

Retry sending a failed message.

Type
(message) => void

selectReaction

Full override of the message reaction handler. It must return a function that accepts reactionType (string). See customize message actions.

Type
function | null
ParameterDescription
messagemessage the action is called on

setEditingState

Set editing state for a message.

Type
(message) => void

setQuotedMessageState

Set quoted-reply state for a message.

Type
(message) => void

shouldShowUnreadUnderlay

Enable/disable the unread underlay background in the message list.

TypeDefault
boolean|undefinedtrue

supportedReactions

List of reactions users can add to messages. See customizing reactions.

TypeDefault
ArrayreactionData

targetedMessage

ID of the highlighted message. Defaults to undefined and resets after the highlight timeout.

Type
string

updateMessage

Upsert a message in local state. Does not call channel.sendMessage (used for optimistic updates).

Type
(message) => void

openPollCreationDialog

Called when the poll creation button is clicked in the attachment picker. Use it to override the default modal UI.

If overridden, a payload is passed with sendMessage from MessageInputContext for use in CreatePoll.

Type
function
ParameterDescription
payload{ sendMessage }

hasCreatePoll

Controls whether the poll creation button is visible.

Type
boolean

Attachment

Renders attachments in MessageList.

Available props:

  • attachment {object}
TypeDefault
ComponentTypeAttachment

AttachmentActions

Renders additional attachment actions (for example, Giphy send/shuffle/cancel).

TypeDefault
ComponentTypeAttachmentActions

AudioAttachment

Renders the audio attachment.

TypeDefault
ComponentTypeAudioAttachment

Card

Renders custom attachment types. See Custom Attachment.

TypeDefault
ComponentTypeCard

CardCover

Renders the main body of Card attachments. See Custom Attachment.

Type
ComponentType

CardFooter

Renders the footer for Card attachments. See Custom Attachment.

Type
ComponentType

CardHeader

Renders the header for Card attachments. See Custom Attachment.

Type
ComponentType

DateHeader

Renders the sticky date header in MessageList.

TypeDefault
ComponentTypeDateHeader

FileAttachment

Renders file attachments in MessageList.

TypeDefault
ComponentTypeFileAttachment

FileAttachmentGroup

Renders a group of file attachments when a message has multiple files.

TypeDefault
ComponentTypeFileAttachmentGroup

FileAttachmentIcon

Renders the file icon for file attachments.

TypeDefault
ComponentTypeFileIcon

FlatList

FlatList component used by MessageList.

TypeDefault
ComponentTypeflat-list-mvcp

Renders image attachments in MessageList.

TypeDefault
ComponentTypeGallery

Giphy

Renders Giphy attachments in MessageList.

TypeDefault
ComponentTypeGiphy

giphyVersion

Giphy image version to render. See the Image Object keys for options.

TypeDefault
string'fixed_height'

InlineDateSeparator

Renders inline date separators between messages more than a day apart.

TypeDefault
ComponentTypeInlineDateSeparator

InlineUnreadIndicator

Renders an inline separator in MessageList to mark the last read message.

TypeDefault
ComponentTypeInlineUnreadIndicator

MessageActionList

Renders the message action list in the message menu.

TypeDefault
ComponentTypeMessageActionList | undefined

MessageActionListItem

Renders a message action item within the action list.

TypeDefault
ComponentTypeMessageActionListItem | undefined

MessageAvatar

Renders the sender avatar in MessageList. Only shown for other users’ messages.

TypeDefault
ComponentTypeMessageAvatar

MessageBounce

Renders the bounce action handler for bounced messages in MessageList.

TypeDefault
ComponentTypeMessageBounce

MessageContent

Renders message content (status, attachments, reactions, etc.) in MessageList.

TypeDefault
ComponentTypeMessageContent

MessageDeleted

Renders a deleted message.

TypeDefault
ComponentTypeMessageDeleted

MessageEditedTimestamp

Renders the “edited” label in MessageList. Only shown for other users’ messages.

TypeDefault
ComponentTypeMessageEditedTimestamp

MessageError

Customize the message error component.

TypeDefault
ComponentTypeMessageError

MessageFooter

Renders the message footer in MessageList.

TypeDefault
ComponentTypeMessageFooter

MessageHeader

Renders the header for a message in MessageList.

Type
ComponentType

MessageMenu

Customize the message menu used for actions and reactions.

TypeDefault
ComponentTypeMessageMenu | undefined

MessageReplies

Shows thread reply count and avatars of users who replied.

TypeDefault
ComponentTypeMessageReplies

MessageRepliesAvatars

Renders avatars of users who replied in the thread.

TypeDefault
ComponentTypeMessageRepliesAvatars

MessageSimple

Renders a message in MessageList.

See Customizing Message UI.

TypeDefault
ComponentTypeMessageSimple

MessageStatus

Renders message status (time and read receipts).

TypeDefault
ComponentTypeMessageStatus

MessageSwipeContent

Renders content when the user swipes a message.

TypeDefault
ComponentTypeMessageSwipeContent | undefined

MessageSystem

Renders system messages that inform users about channel changes. System messages are part of history and have type: "system".

System messages appear when:

TypeDefault
ComponentTypeMessageSystem

MessageText

Renders message text. By default, the SDK uses Simple Markdown. If you override this, you must handle markdown rendering yourself.

TypeDefault
ComponentTyperenderText

MessageReactionPicker

Reaction selector shown in the message menu on long-press.

TypeDefault
ComponentTypeMessageReactionPicker | undefined

MessageUserReactionsAvatar

Renders an avatar in message user reactions within the message menu.

TypeDefault
ComponentTypeMessageUserReactionsAvatar | undefined

MessageUserReactionsItem

Customize an individual user reaction item in MessageMenu’s MessageUserReactions (avatar, reaction type, user name, etc.).

TypeDefault
ComponentTypeMessageUserReactionsItem | undefined

MessageUserReactions

Renders the reactions list in the message menu.

TypeDefault
ComponentTypeMessageUserReactions | undefined

MessageUserReactionsAvatar

Renders an avatar in message user reactions within the message menu.

TypeDefault
ComponentTypeMessageUserReactionsAvatar | undefined

MessageUserReactionsItem

Customize an individual user reaction item in MessageMenu’s MessageUserReactions (avatar, reaction type, user name, etc.).

TypeDefault
ComponentTypeMessageUserReactionsItem | undefined

MessageUserReactions

Renders the reactions list in the message menu.

TypeDefault
ComponentTypeMessageUserReactions | undefined

ReactionListBottom

Renders the reactions list below the message bubble.

TypeDefault
ComponentTypeReactionListBottom

ReactionListTop

Renders the reactions list above the message bubble.

TypeDefault
ComponentTypeReactionListTop

ScrollToBottomButton

Renders a button that scrolls the message list to the bottom.

TypeDefault
ComponentTypeScrollToBottomButton

TypingIndicator

Renders the typing indicator in MessageList.

TypeDefault
ComponentTypeTypingIndicator

TypingIndicatorContainer

Renders the container for the typing indicator in MessageList.

TypeDefault
ComponentTypeTypingIndicatorContainer

UrlPreview

Renders URL previews in MessageList.

TypeDefault
ComponentTypeCard

VideoThumbnail

Renders video thumbnails for video attachments in MessageList.

TypeDefault
ComponentTypeVideoThumbnail

PollContent

A Component prop used to render the content of the Poll component in MessageList.

The component has full access to the entire Poll reactive state through the usePollState hook.

TypeDefault
ComponentTypePollContent

Props

PollHeader

A Component prop used to render the header of the PollContent component.

TypeDefault
ComponentTypePollHeader
PollButtons

A Component prop used to render the buttons of the PollContent component.

TypeDefault
ComponentTypePollButtons