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

ChannelStateContext

ChannelStateContext is provided by Channel and exposes state for the active channel. Access it with useChannelStateContext.

Best Practices

  • Use state values from context instead of storing duplicate local copies.
  • Treat messages, members, and read as reactive sources for UI updates.
  • Prefer channelCapabilities to gate UI actions instead of hard-coding permissions.
  • Use suppressAutoscroll to respect user scroll position for long histories.
  • Guard against null channel or error states in custom components.

Basic Usage

Pull values from ChannelStateContext with our custom hook:

const { channel, watchers } = useChannelStateContext();

Values

ValueDescriptionType
channelThe active StreamChat channel instance consumed by Channel and its children.Channel
channelCapabilitiesThe allowed channel permissions for the currently connected user.Record<string, boolean>
channelConfigConfiguration for the active channel.ChannelConfig
channelUnreadUiStateRead state maintained for unread UI such as UnreadMessagesSeparator and UnreadMessagesNotification. Includes last_read, unread_messages, first_unread_message_id, and last_read_message_id.ChannelUnreadUiState
errorError from loading the channel, if any. Otherwise null.Error | null
findURLFnCustom function to identify URLs in a string for later generation of link previews. See the guide Link Previews in Message Input for more.(text: string) => string[]
giphyVersionForwarded from the Channel component prop giphyVersion. Defaults to 'fixed_height'.string
hasMoreWhether the channel has older messages to paginate.boolean
hasMoreNewerWhether the channel has newer messages to paginate.boolean
highlightedMessageIdUsed internally for jump-to-message. The message with this ID is highlighted after the jump.string
imageAttachmentSizeHandlerForwarded from the Channel component prop imageAttachmentSizeHandler.(a: Attachment, e: HTMLElement) => ImageAttachmentConfiguration
loadingWhether the channel is loading.boolean
loadingMoreWhether older messages are loading.boolean
loadingMoreNewerWhether newer messages are loading as the user scrolls down. Used internally by VirtualizedMessageList.boolean
membersMembers of this channel. Members are permanent; watchers are currently online.Record<string, ChannelMemberResponse>
messagesArray of message objects.LocalMessage[]
mutesArray of muted users for the current channel.Mute[]
notificationsTemporary notifications added to MessageList on specific actions.{id: string, text: string, type: 'success' | 'error'}[]
onLinkPreviewDismissedCustom function to react to link preview dismissal. See the guide Link Previews in Message Input for more.(linkPreview: LinkPreview) => void
pinnedMessagesMessages that are pinned in the channel.LocalMessage[]
readRead state for each channel member.Record<string, ChannelReadState>
shouldGenerateVideoThumbnailForwarded from the Channel component prop shouldGenerateVideoThumbnail.boolean
suppressAutoscrollWhether auto-scroll to bottom is suppressed. Used by MessageList and VirtualizedMessageList.boolean
threadParent message for a thread, if there is one. Otherwise null.LocalMessage | null
threadHasMoreWhether there are more messages available in the active thread.boolean
threadLoadingMoreWhether the thread is currently loading more messages.boolean
threadMessagesArray of messages within a thread.LocalMessage[]
threadSuppressAutoscrollWhether scrolling to the bottom is prevented in the thread. Used internally by MessageList and VirtualizedMessageList.boolean
videoAttachmentSizeHandlerForwarded from the Channel component prop videoAttachmentSizeHandler.(a: Attachment, e: HTMLElement) => VideoAttachmentConfiguration
watcher_countLegacy snake-case watcher count from channel state.number
watcherCountThe number of watchers on the channel.number
watchersUsers who are currently watching the channel.Record<string, UserResponse>