This is beta documentation for Stream Chat React SDK v14. For the latest stable version, see the latest version (v13) .

Message

Message provides the logic and MessageContext for a single message. The rendered UI is delegated to a message component such as MessageSimple or your own custom message UI.

Most apps do not render Message directly. It is created by MessageList, VirtualizedMessageList, and Thread.

Best Practices

  • Treat Message as the logic layer and MessageContext as the source of truth for rendering.
  • Set shared message UI defaults with WithComponents.
  • Use list-level Message props when you need one-off customization for a single list.
  • Keep custom message UIs based on useMessageContext() instead of assuming prop injection.
  • Leave request/notification handling to the built-in message hooks unless you need custom behavior.

Basic Usage

Message is usually configured indirectly through the surrounding list.

To set a shared default message UI for a Channel subtree, register it with WithComponents:

import {
  Channel,
  ChannelHeader,
  MessageInput,
  MessageList,
  Thread,
  Window,
  WithComponents,
  useMessageContext,
} from "stream-chat-react";

const CustomMessage = () => {
  const { message } = useMessageContext();

  return <div>{message.text}</div>;
};

const App = () => (
  <WithComponents
    overrides={{
      Message: CustomMessage,
      VirtualMessage: CustomMessage,
    }}
  >
    <Channel>
      <Window>
        <ChannelHeader />
        <MessageList />
        <MessageInput />
      </Window>
      <Thread />
    </Channel>
  </WithComponents>
);

If you only want to customize one list, use the list-level Message prop instead:

import { MessageList, Thread, VirtualizedMessageList } from "stream-chat-react";

<MessageList Message={CustomMessage} />;
<Thread Message={CustomMessage} />;
<VirtualizedMessageList Message={CustomMessage} />;

UI Customization

Message itself does not render the message bubble. It creates the MessageContext value and then renders the current message UI component.

Use:

  • WithComponents to set subtree defaults for Message and VirtualMessage
  • MessageList, Thread, or VirtualizedMessageList props for local overrides
  • MessageContext and the message hooks inside custom UIs

Props

PropDescriptionType
autoscrollToBottomKeeps a virtualized list pinned to the bottom when message height changes.() => void
closeReactionSelectorOnClickCloses ReactionSelector after a reaction is chosen.boolean
deliveredToUsers who have confirmed delivery of the message.UserResponse[]
disableQuotedMessagesDisables quote-message actions for this message.boolean
groupStylesGrouping styles for the message.GroupStyle[]
highlightedHighlights and focuses the message when mounted.boolean
initialMessageMarks the message as the first item in a thread list.boolean
lastOwnMessageLatest own message in the currently rendered set.LocalMessage
lastReceivedIdLatest message ID in the current channel.string | null
messageMessage object used to build the context value.LocalMessage
MessageCustom UI component to render for this message. Overrides the current ComponentContext value.React.ComponentType<MessageUIComponentProps>
messageActionsAllowed message actions such as edit, delete, reply, or react.MessageActionsArray
messageListRectDOM rect of the parent list.DOMRect
onlySenderCanEditRestricts editing to the message author.boolean
onMentionsClickCustom mention click handler.ChannelActionContextValue["onMentionsClick"]
onMentionsHoverCustom mention hover handler.ChannelActionContextValue["onMentionsHover"]
onUserClickCustom user click handler.UserEventHandler
onUserHoverCustom user hover handler.UserEventHandler
openThreadCustom open-thread handler.ChannelActionContextValue["openThread"]
reactionDetailsSortSort options for loading reaction details.ReactionSort
readByUsers who have read the message.UserResponse[]
renderTextCustom text renderer used by MessageText or StreamedMessageText.MessageContextValue["renderText"]
retrySendMessageCustom retry-send handler.ChannelActionContextValue["retrySendMessage"]
returnAllReadDataKeeps read receipts for every own message instead of only the latest one.boolean
showAvatarControls whether the message layout shows an avatar column.boolean | "incoming" | "outgoing"
sortReactionDetailsLegacy comparator for reaction details.ReactionDetailsComparator
sortReactionsComparator for grouped reactions.ReactionsComparator
threadListMarks the message as part of a thread list.boolean
unsafeHTMLRenders HTML instead of markdown.boolean

Message also accepts optional text-builder props for the default request notifications:

  • getDeleteMessageErrorNotification
  • getFetchReactionsErrorNotification
  • getFlagMessageErrorNotification
  • getFlagMessageSuccessNotification
  • getMarkMessageUnreadErrorNotification
  • getMarkMessageUnreadSuccessNotification
  • getMuteUserErrorNotification
  • getMuteUserSuccessNotification
  • getPinMessageErrorNotification