This is beta documentation for Stream Chat React Native SDK v9. For the latest stable version, see the latest version (v8) .

MessageInputContext

MessageInputContext is provided by Channel. If you are not familiar with the React Context API, see the React docs.

Best Practices

  • Prefer useMessageInputContext for consistent access and typings.
  • Use context handlers (sendMessage, editMessage) to keep behavior aligned with the SDK.
  • Keep input-related props stable to avoid re-renders while typing.
  • Use openAttachmentPicker and closeAttachmentPicker helpers to keep picker state consistent.
  • Respect cooldowns and permissions before allowing sends or uploads.

Basic Usage

Consume MessageInputContext in any child of Channel:

import { useContext } from "react";
import { MessageInputContext } from "stream-chat-react-native";

const { sendMessage, openAttachmentPicker } = useContext(MessageInputContext);

Alternatively, use the useMessageInputContext hook.

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

const { sendMessage, openAttachmentPicker } = useMessageInputContext();

Value

additionalTextInputProps

Extra props passed to the underlying TextInput in MessageInput.

Type
object

allowSendBeforeAttachmentsUpload

When enabled, messages can be sent before all attachments have finished uploading.

TypeDefault
Boolean-

asyncMessagesLockDistance

Pixels the user must drag upward to lock recording and lift their finger without stopping it.

TypeDefault
Number50

asyncMessagesMinimumPressDuration

Minimum press duration (ms) on the record button to start voice recording.

TypeDefault
Number500

asyncMessagesMultiSendEnabled

When enabled, recordings don't send immediately. They stack in the composer so users can send multiple voice recordings in one message.

TypeDefault
Booleantrue

asyncMessagesSlideToCancelDistance

Pixels the user must drag toward the leading side to cancel voice recording.

TypeDefault
Number100

audioRecorderManager

Instance of AudioRecorderManager used to manage audio recording state internally.

Type
AudioRecorderManager

audioRecordingEnabled

Enable or disable audio recording.

TypeDefault
Booleanfalse

attachmentPickerBottomSheetHeight

Height of the attachment picker bottom sheet when open.

TypeDefault
Number40% of Window Height

compressImageQuality

Image compression quality before upload.

On iOS, values >= 0.8 usually keep quality while reducing size. A value of 0.8 can roughly halve file size vs 1.0.

TypeDefault
number 0 to 1
(1 is best quality)
iOS: 0.8
Android: 1

closeAttachmentPicker

Dismiss the attachment picker, if its already open.

Type
Function

closePollCreationDialog

Function called whenever the close button is pressed on the poll creation modal. Has no effect if PollCreateContent is custom.

Type
function

createPollOptionGap

Vertical gap between poll options in the poll creation dialog.

Type
Number

deleteVoiceRecording

Deletes the current voice recording.

Type
() => Promise<void>

doFileUploadRequest

editMessage

Handles the edit message event on the message input by taking the new message as input and updating the message for the client.

Type
Function

The function takes an object as a parameter with the following properties:

ParameterDescription
localMessageContains the message data that will be shown in the UI immediately
optionsContains options for sending/updating the message

handleAttachButtonPress

Customize behavior when the AttachButton is pressed in the message input.

Type
() => void

hasCameraPicker

Enable the camera picker in MessageInput.

TypeDefault
Booleantrue

hasCommands

Enable commands in MessageInput.

TypeDefault
booleantrue

hasFilePicker

Enable the file picker in MessageInput.

TypeDefault
Booleantrue

hasImagePicker

Enable the image picker in MessageInput.

TypeDefault
Booleantrue

inputBoxRef

Ref for TextInput component within MessageInput

messageInputFloating

Whether the message input is floating or not.

TypeDefault
Booleanfalse

messageInputHeightStore

Store instance for tracking the message input height.

Type
MessageInputHeightStore

openAttachmentPicker

Opens the attachment picker bottom sheet, if its not open.

Type
Function

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 }

pickAndUploadImageFromNativePicker

Opens the native image picker and uploads the selected image.

Type
() => Promise<void>

pickFile

Opens the native document/file picker and uploads the selected files.

Type
() => Promise<void>

sendMessage

Sends a composed message within MessageInput component to channel. This function is attached to onPress handler of SendButton. The message optimistically gets added to message list UI first, before actually making API call to server. During this intermediate stage, MessageStatus component will display an indicator for "pending" state.

Type
Function

The function takes an object as a parameter with the following properties:

ParameterDescription
localMessageContains the message data that will be shown in the UI immediately
messageContains the data that will be sent to the backend
optionsContains options for sending/updating the message

setInputBoxRef

Setter function for inputBoxRef

Type
(ref) => void

showPollCreationDialog

A boolean signifying whether the poll creation dialog is shown or not. Will always be false if PollCreateContent is custom.

Type
boolean

startVoiceRecording

Starts a new voice recording session.

Type
() => Promise<boolean | undefined>

stopVoiceRecording

Stops the current voice recording.

Type
() => Promise<void>

takeAndUploadImage

Function to click an image using the device camera and upload it.

Type
() => Promise<void>

thread

Can be a LocalMessage or ThreadType. Setting it indicates a thread is open. Both types are interchangeable.

With Thread, this displays the thread. With the standard MessageList, it keeps singleton components in OverlayProvider in sync.

Set thread on all Channel components when a thread is open.

Type
object

uploadNewFile

Function to upload an attached file in MessageInput. This invokes the Message composer Attachment Manager's uploadFiles method to handle the file upload process.

This handles the abort controller to make sure that the upload can be cancelled if needed.

Type
(file: File) => Promise

uploadVoiceRecording

Uploads the current voice recording. When multiSendEnabled is true, the recording stacks in the composer instead of being sent immediately.

Type
(multiSendEnabled: boolean) => Promise<void>

Components Props

AttachButton

Renders the attach button next to the input box.

TypeDefault
ComponentTypeAttachButton

AttachmentPickerSelectionBar

Renders the attachment picker selection bar (image, file, camera icons).

TypeDefault
ComponentTypeundefined | AttachmentPickerSelectionBar

AttachmentUploadPreviewList

Renders previews of attached files and images in MessageInput.

TypeDefault
ComponentTypeAttachmentUploadPreviewList

AudioAttachmentUploadPreview

Customize the audio attachment upload preview in MessageInput.

TypeDefault
ComponentTypeAudioAttachmentUploadPreview

AudioRecorder

Custom UI for audio recorder controls in MessageInput.

TypeDefault
ComponentTypeAudioRecorder

AudioRecordingInProgress

Custom UI for an in-progress audio recording in MessageInput (waveform, duration, etc.).

TypeDefault
ComponentTypeAudioRecordingInProgress

AudioRecordingLockIndicator

Custom lock indicator for audio recording in MessageInput.

TypeDefault
ComponentTypeAudioRecordingLockIndicator

AudioRecordingPreview

Custom UI to preview and play an audio recording in MessageInput.

TypeDefault
ComponentTypeAudioRecordingPreview

AudioRecordingWaveform

Custom waveform UI for audio recording in MessageInput.

TypeDefault
ComponentTypeAudioRecordingWaveform

AutoCompleteSuggestionHeader

Renders the autocomplete suggestion header.

TypeDefault
ComponentTypeAutoCompleteSuggestionHeader

AutoCompleteSuggestionItem

Renders an autocomplete suggestion item.

TypeDefault
ComponentTypeAutoCompleteSuggestionItem

AutoCompleteSuggestionList

Renders the autocomplete suggestion list.

TypeDefault
ComponentTypeAutoCompleteSuggestionList

CooldownTimer

Renders a countdown timer for message send cooldowns in MessageInput.

TypeDefault
ComponentTypeCooldownTimer

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.

TypeDefault
ComponentTypeCreatePollContent

FileAttachmentUploadPreview

Customize the file attachment upload preview in MessageInput.

TypeDefault
ComponentTypeFileAttachmentUploadPreview

FileUploadInProgressIndicator

Renders a progress indicator for file uploads in MessageInput.

Type
ComponentType

FileUploadNotSupportedIndicator

Renders an indicator when file upload is not supported.

Type
ComponentType

FileUploadRetryIndicator

Renders a retry indicator for failed file uploads.

Type
ComponentType

ImageAttachmentUploadPreview

Customize the image attachment upload preview in MessageInput.

TypeDefault
ComponentTypeImageAttachmentUploadPreview

ImageUploadInProgressIndicator

Renders a progress indicator for image uploads in MessageInput.

Type
ComponentType

ImageUploadNotSupportedIndicator

Renders an indicator when image upload is not supported.

Type
ComponentType

ImageUploadRetryIndicator

Renders a retry indicator for failed image uploads.

Type
ComponentType

Input

Renders the UI for the enclosed MessageInput. See Customizing Message Input.

Type
ComponentType

InputButtons

Renders action buttons (AttachButton) on the left side of the MessageInput.

TypeDefault
ComponentTypeInputButtons

MessageComposerLeadingView

Custom UI component to override the leading side of the composer container.

Type
ComponentType

MessageComposerTrailingView

Custom UI component to override the trailing side of the composer container.

Type
ComponentType

MessageInputHeaderView

Custom UI component to override the message input header content.

Type
ComponentType

MessageInputLeadingView

Custom UI component to override the leading side of the input row.

Type
ComponentType

MessageInputTrailingView

Custom UI component to override the trailing side of the input row.

Type
ComponentType

SendButton

Renders the send message button inside MessageInput.

TypeDefault
ComponentTypeSendButton

SendMessageDisallowedIndicator

Renders an indicator when the current user can't send messages.

TypeDefault
ComponentTypeSendMessageDisallowedIndicator

ShowThreadMessageInChannelButton

Renders a checkbox in Thread that sets show_in_channel to true when checked.

TypeDefault
ComponentTypeShowThreadMessageInChannelButton

StartAudioRecordingButton

Custom mic button for audio recording in MessageInput.

TypeDefault
ComponentTypeStartAudioRecordingButton

StopMessageStreamingButton

Custom UI component to render a button that stops message streaming (for AI-generated responses).

Type
ComponentType | null

VideoAttachmentUploadPreview

Customize the video attachment upload preview in MessageInput.

TypeDefault
ComponentTypeVideoAttachmentUploadPreview