MessageInput Hooks

Public MessageInput hooks:

Best Practices

  • Use hooks as the source of truth for composer and attachment state.
  • Keep sendability checks (useMessageComposerHasSendableData) in one place.
  • Treat attachment counts as derived state, not user-visible truth.
  • Respect useCooldownTimer in custom inputs to avoid rate-limit issues.
  • Avoid side effects inside hooks; trigger side effects in handlers instead.

useMessageComposer

Retrieve the corresponding MessageComposer instance.

useMessageComposerHasSendableData

Returns whether a message can be composed and sent. Useful for enabling/disabling the send button.

useAttachmentManagerState

Returns an object with relevant data concerning attachments. The data carried by the object are:

  • attachments
  • availableUploadSlots
  • blockedUploadsCount
  • failedUploadsCount
  • isUploadEnabled
  • pendingUploadsCount
  • successfulUploadsCount
  • uploadsInProgressCount

useCanCreatePoll

Returns whether a poll can be created. Useful for poll creation forms.

useMessageInputControls

Contributes the following to MessageInputContextValue:

  • handleSubmit
  • onPaste
  • recordingController
  • textareaRef

useCooldownTimer

A custom hook that sets up the CooldownTimer and manages its state.