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

ChatContext

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

Best Practices

  • Prefer useChatContext over useContext(ChatContext) for consistency.
  • Read isOnline before showing connection-dependent UI or actions.
  • Keep a single client instance in context to avoid race conditions.
  • Use the context-provided ImageComponent to keep image rendering consistent.
  • Treat mutedUsers as read-only UI state; change it via client methods.

Basic Usage

Consume ChatContext in any child of Chat:

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

const { client, isOnline } = useContext(ChatContext);

Alternatively, use the useChatContext hook.

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

const { client, isOnline } = useChatContext();

Value

client

Stream Chat client instance.

appSettings

App settings for the connected client.

connectionRecovering

true when the WebSocket connection is disconnected and being recovered.

Type
boolean

enableOfflineSupport

Enables offline support for the chat. When enabled, messages and channels are cached locally and the app can work without an internet connection. Requires @op-engineering/op-sqlite to be installed.

See the offline support documentation for more details on setting this up.

TypeDefault
Booleanfalse

isOnline

true when the current user is connected.

Type
boolean

mutedUsers

Users muted by the current user.

Type
array

isMessageAIGenerated

A callback that determines whether a message was AI generated. The default returns false.

TypeDefault
(message: LocalMessage) => boolean() => false

ImageComponent

Drop-in replacement for all underlying Image components in the SDK. Useful for offline image caching. See the Offline Support Guide.

TypeDefault
ComponentTypeImage