ThreadContext

ThreadContext provides thread data via React context. It’s populated by ThreadProvider.

Best Practices

  • Prefer ThreadProvider when you have a Thread instance already available.
  • Keep ThreadProvider scoped to the thread view to avoid unnecessary context updates.
  • Rely on Thread’s built-in fallback to Channel state only when needed.
  • Avoid mixing multiple thread sources in the same subtree.
  • Keep thread data updates centralized to prevent inconsistent UI.

ThreadProvider

ThreadProvider wraps Channel and provides a Thread instance. The Channel wrapper is a temporary compatibility layer while the SDK transitions to using a Thread instance directly.

Thread prioritizes the provided Thread instance when rendered under ThreadProvider; otherwise it falls back to thread data from Channel state.

Basic Usage

import { Thread, ThreadProvider } from "stream-chat-react";

<ThreadProvider thread={/*...*/}>
  <Thread />
</ThreadProvider>;