MessageComposer

MessageComposer provides UI and functionality for composing messages (attachment picker, commands, mentions, autocomplete). It must be rendered inside Channel.

Best Practices

  • Render MessageComposer inside Channel to ensure composer state is available.
  • Customize via Channel props first to keep behavior consistent.
  • Keep additionalTextInputProps stable to avoid re-renders.
  • Respect cooldowns and permissions to prevent invalid sends.
  • Use built-in components for attachments and audio before rolling your own.

General Usage

import { StreamChat } from "stream-chat";
import {
  Chat,
  Channel,
  MessageList,
  MessageComposer,
  OverlayProvider,
} from "stream-chat-react-native";

const client = StreamChat.getInstance("api_key");

export const App = () => (
  <OverlayProvider>
    <Chat client={client}>
      <Channel channel={channel}>
        <MessageList />
        <MessageComposer />
      </Channel>
    </Chat>
  </OverlayProvider>
);

TypeScript

File type

The File type is now exported from the stream-chat-react-native package and extends the FileReference type from the stream-chat package. It looks like this:

import { FileReference } from "stream-chat";

export type File = FileReference;

Props

Note:

Most configuration lives on the Channel component. See Customizing Message Composer for UI customization.

Prop Description Type
attachmentSelectionBarHeight Height of the attachment selection bar in the attachment picker. Defaults to 52. number
additionalTextInputProps Extra props passed to the underlying TextInput in MessageComposer. object
asyncMessagesLockDistance Pixels the user must drag upward to lock recording and lift their finger without stopping it. Defaults to 50. number
asyncMessagesMinimumPressDuration Minimum press duration (ms) on the record button to start voice recording. Defaults to 500. number
audioRecordingSendOnComplete Controls what happens after a completed voice recording upload. When true, sends the voice recording immediately after upload. When false, keeps it in the composer so the user can add text, attachments, or more recordings before sending. Defaults to false. boolean
asyncMessagesSlideToCancelDistance Pixels the user must drag toward the leading side to cancel voice recording. Defaults to 75. number
audioRecordingEnabled Enable or disable audio recording. Defaults to false. boolean
channel Channel instance from the Stream Chat client. Channel
closeAttachmentPicker Dismiss the attachment picker, if its already open. function
closePollCreationDialog Function called whenever the close button is pressed on the poll creation modal. Has no effect if PollCreateContent is custom. function
compressImageQuality Image compression quality used by the message input upload flow. number
editing Whether the message input is in edit mode. -
inputBoxRef Ref for TextInput component within MessageComposer. React ref
isOnline The value is true when current user is connected to chat. boolean
messageInputFloating Renders the input in floating mode with adjusted container behavior/styles. Defaults to false. boolean
messageInputHeightStore Store used internally to track and share the current input height. MessageInputHeightStore
openPollCreationDialog Function used to open the poll creation dialog. () => void
members Members of current channel. This value is received from backend when you query a channel, either using client.queryChannels() or channel.watch() API call. Note: these calls return only up to 100 members; use client.queryMembers() for larger channels. object
sendMessage Sends a composed message within MessageComposer component to channel. Attached to the onPress handler of SendButton. The message optimistically gets added to message list UI first, before making API call to server. function
showPollCreationDialog A boolean signifying whether the poll creation dialog is shown or not. Will always be false if PollCreateContent is custom. boolean
createPollOptionGap Controls spacing between poll options in the poll creation modal. number
threadList Indicates the Channel is rendering a thread. Used to avoid concurrency issues between the main channel and thread. boolean
watchers Watchers of current channel. This value is received from backend when you query a channel, either using client.queryChannels() or channel.watch() API call. Note: these calls return only up to 100 watchers; use Channel Pagination for more. object

UI Component Overrides

The UI components used by MessageComposer are read from ComponentsContext and can be customized via WithComponents. Wrap MessageComposer (or any ancestor) with WithComponents and pass the components you want to override.

import { WithComponents } from "stream-chat-react-native";

<WithComponents
  overrides={{ SendButton: CustomSendButton, Reply: CustomReply }}
>
  <Channel channel={channel}>
    <MessageList />
    <MessageComposer />
  </Channel>
</WithComponents>;

The following components can be overridden:

Prop Description Type Default
AttachmentUploadPreviewList Renders previews of attached files and images in MessageComposer. ComponentType AttachmentUploadPreviewList
AttachmentPickerSelectionBar Renders the attachment picker selection bar (image, file, camera icons). ComponentType undefined | AttachmentPickerSelectionBar
AudioRecorder Custom UI for audio recorder controls in MessageComposer. ComponentType AudioRecorder
AudioRecordingInProgress Custom UI for an in-progress audio recording in MessageComposer (waveform, duration, etc.). ComponentType AudioRecordingInProgress
AudioRecordingLockIndicator Custom lock indicator for audio recording in MessageComposer. ComponentType AudioRecordingLockIndicator
AudioRecordingPreview Custom UI to preview and play an audio recording in MessageComposer. ComponentType AudioRecordingPreview
AudioRecordingWaveform Custom waveform UI for audio recording in MessageComposer. ComponentType AudioRecordingWaveform
AutoCompleteSuggestionList Renders the autocomplete suggestion list. ComponentType AutoCompleteSuggestionList
CooldownTimer Renders a countdown timer for message send cooldowns in MessageComposer. ComponentType CooldownTimer
MessageComposerLeadingView Custom component rendered in the leading composer slot. ComponentType MessageComposerLeadingView
MessageComposerTrailingView Custom component rendered in the trailing composer slot. ComponentType MessageComposerTrailingView
CreatePollContent A custom UI component used to render the entire poll creation form. It has access to the CreatePollContentContext values by default through the useCreatePollContentContext hook. ComponentType CreatePollContent
Input Renders the UI for the enclosed MessageComposer. See Customizing Message Composer. ComponentType -
InputView Renders the default inner input body (command chip, AutoCompleteInput, and the show-in-channel button). Override to fully replace the inner layout of the composer input row. ComponentType InputView
InputButtons Renders action buttons (AttachButton) on the left side of the MessageComposer. ComponentType InputButtons
Reply Renders a preview of the parent message for quoted replies. ComponentType Reply
SendButton Renders the send message button inside MessageComposer. ComponentType SendButton
ShowThreadMessageInChannelButton Renders a checkbox in Thread that sets show_in_channel to true when checked. ComponentType ShowThreadMessageInChannelButton
StartAudioRecordingButton Custom mic button for audio recording in MessageComposer. ComponentType StartAudioRecordingButton
StopMessageStreamingButton Custom button to stop AI generation, shown instead of SendButton in MessageComposer. component StopMessageStreamingButton
MessageInputHeaderView Custom component rendered above the input body for reply/edit/preview content. ComponentType MessageInputHeaderView
MessageInputLeadingView Custom component rendered in the leading inline input area. ComponentType MessageInputLeadingView
MessageInputTrailingView Custom component rendered in the trailing inline input area. ComponentType MessageInputTrailingView
MessageInputFooterView Custom component rendered below the input body. Renders null by default; override to add footer content beneath the composer. ComponentType MessageInputFooterView
TextInputComponent The component prop to override the default TextInput component used in the message input's AutoCompleteInput. ComponentType Default React Native's TextInput
Add Chat to my app: getstream.io/SKILL.md

The fastest way to build with Stream. Start a new project or improve an existing one. Full CLI and documentation integration out of the box.


Ask your agent:

/stream Build me a Social App with Feeds and Moderation.
/stream Any livestream calls running?
/stream Chat React Native v9: <Your Question>