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>
);MessageComposer
MessageComposer provides UI and functionality for composing messages (attachment picker, commands, mentions, autocomplete). It must be rendered inside Channel.
Best Practices
- Render
MessageComposerinsideChannelto ensure composer state is available. - Customize via
Channelprops first to keep behavior consistent. - Keep
additionalTextInputPropsstable 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
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
Most configuration lives on the Channel component. See Customizing Message Composer for UI customization.
| Prop | Description | Type |
|---|---|---|
attachmentPickerBottomSheetHeight | Height of the attachment picker bottom sheet when open. Defaults to 40% of Window Height. | number |
attachmentSelectionBarHeight | Height of the attachment selection bar in the attachment picker. Defaults to 52. | number |
bottomInset | Offsets the MessageList when the attachment picker opens. For most apps, set bottomInset on Channel instead. Use this prop only to override bottomInset from AttachmentPickerContext for a specific composer instance. | number | undefined |
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 true. | boolean |
asyncMessagesSlideToCancelDistance | Pixels the user must drag toward the leading side to cancel voice recording. Defaults to 100. | 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 |
cooldownEndsAt | The time at which the active cool-down will end. | Date |
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 |
selectedPicker | Value is 'images' when image attachment picker is open, else undefined. | 'images' | undefined |
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 CreatePollContext values by default through the useCreatePollContext hook. | ComponentType | CreatePollContent |
Input | Renders the UI for the enclosed MessageComposer. See Customizing Message Composer. | ComponentType | - |
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 |
TextInputComponent | The component prop to override the default TextInput component used in the message input's AutoCompleteInput. | ComponentType | Default React Native's TextInput |