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

ChatContext

ChatContext is provided by the Chat component. All SDK components under Chat can access it via the useChatContext hook.

Best Practices

  • Access context only inside children of Chat to avoid null/undefined values.
  • Prefer setActiveChannel over manual prop wiring when switching channels.
  • Use channelsQueryState to drive loading and error UI consistently.
  • Keep context consumers narrow to avoid unnecessary re-renders.
  • Treat customClasses and theme as read-only configuration in context consumers.

Basic Usage

Pull values from ChatContext with our custom hook:

const { client, setActiveChannel } = useChatContext();

Values

ValueDescriptionType
channelThe currently active channel, which powers the Channel component.Channel
channelsQueryStateExposes channel-list query state and setters through queryInProgress, setQueryInProgress, error, and setError. queryInProgress can be uninitialized, reload, load-more, or null.ChannelsQueryState
clientForwarded from the Chat component prop client.StreamChat
closeMobileNavCloses the mobile navigation.() => void
customClassesForwarded from the Chat prop customClasses.CustomClasses
getAppSettingsCallback to fetch app settings, including image and file upload config.() => Promise<AppSettingsAPIResponse>
latestMessageDatesByChannelMap of channel IDs to the date of the user’s latest message. Used to determine slow mode countdown.{ [key: string]: Date }
mutesUsers muted by the connected user.Mute[]
navOpenWhether the mobile nav is open at mobile breakpoints. Defaults to true.boolean
openMobileNavOpens the mobile navigation.() => void
setActiveChannelSets the active channel. Used by ChannelList to switch channels, and can be overridden via context.(newChannel?: Channel, watchers?: { limit?: number; offset?: number }) => void
themeForwarded from the Chat prop theme.string
useImageFlagEmojisOnWindowForwarded from the Chat prop useImageFlagEmojisOnWindows. Defaults to false.boolean