Skip to main content

ChatContext

The ChatContext is exposed by the Chat component. Since Chat wraps the entire chat application, all other components in the library have access to the values stored in this context. You can access the context values by calling the useChatContext custom hook.

Basic Usage#

Pull values from context with our custom hook:

const { client, setActiveChannel } = useChatContext();

Values#

client#

The StreamChat client instance. Any methods from the stream-chat-js API interface can be run off this object.

Type
object

channel#

The currently active channel, which populates the Channel component.

Type
Channel

closeMobileNav#

The function to close mobile navigation.

Type
function

customClasses#

Object containing custom CSS classnames to override the library's default container CSS. See CSS and Theming for implementation assistance.

Type
object

getAppSettings#

The callback function used to get available client-side app settings, includes image and file upload config.

Type
function

latestMessageDatesByChannel#

Object containing the date of the latest message sent by the current user by channels (this is used to detect if slow mode countdown should be started)

Type
{ [key: string]: Date }

mutes#

An array of users that have been muted by the connected user.

Type
Mute[]

navOpen#

When the screen width is at a mobile breakpoint, whether or not the mobile navigation menu is open.

TypeDefault
booleantrue

openMobileNav#

The function to open mobile navigation.

Type
function

setActiveChannel#

A function to set the currently active channel. This is used in the ChannelList component to navigate between channels. You can override the default behavior by pulling it from context and then utilizing the function.

Type
function

theme#

Deprecated and to be removed in a future major release. Use the customStyles prop to adjust CSS variables and customize the theme of your app.

Type
Theme

useImageFlagEmojisOnWindow#

Windows 10 does not support country flag emojis out of the box. It chooses to render these emojis as characters instead. Stream Chat can override this behavior by loading a custom web font that will render images instead (PNGs or SVGs depending on the platform). Set this prop to true if you want to use these custom emojis for Windows users.

TypeDefault
booleanfalse

Did you find this page helpful?