# ChannelStateContext

`ChannelStateContext` is provided by [`Channel`](/chat/docs/sdk/react/components/core-components/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:

```tsx
const { channel, watchers } = useChannelStateContext();
```

## Values

| Value                          | Description                                                                                                                                                                                               | Type                                                              |
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| `channel`                      | The active `StreamChat` channel instance consumed by `Channel` and its children.                                                                                                                          | `Channel`                                                         |
| `channelCapabilities`          | The allowed channel permissions for the currently connected user.                                                                                                                                         | `Record<string, boolean>`                                         |
| `channelConfig`                | Configuration for the active channel.                                                                                                                                                                     | `ChannelConfig`                                                   |
| `channelUnreadUiState`         | Read 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`                                            |
| `error`                        | Error from loading the channel, if any. Otherwise `null`.                                                                                                                                                 | `Error \| null`                                                   |
| `findURLFn`                    | Custom function to identify URLs in a string for later generation of link previews. See the guide [Link Previews in Message Composer](/chat/docs/sdk/react/guides/customization/link-previews/) for more. | `(text: string) => string[]`                                      |
| `giphyVersion`                 | Forwarded from the `Channel` component [prop `giphyVersion`](/chat/docs/sdk/react/components/core-components/channel#giphyversion/). Defaults to `'fixed_height'`.                                        | `string`                                                          |
| `hasMore`                      | Whether the channel has older messages to paginate.                                                                                                                                                       | `boolean`                                                         |
| `hasMoreNewer`                 | Whether the channel has newer messages to paginate.                                                                                                                                                       | `boolean`                                                         |
| `highlightedMessageId`         | Used internally for jump-to-message. The message with this ID is highlighted after the jump.                                                                                                              | `string`                                                          |
| `imageAttachmentSizeHandler`   | Forwarded from the `Channel` component [prop `imageAttachmentSizeHandler`](/chat/docs/sdk/react/components/core-components/channel#imageattachmentsizehandler/).                                          | `(a: Attachment, e: HTMLElement) => ImageAttachmentConfiguration` |
| `loading`                      | Whether the channel is loading.                                                                                                                                                                           | `boolean`                                                         |
| `loadingMore`                  | Whether older messages are loading.                                                                                                                                                                       | `boolean`                                                         |
| `loadingMoreNewer`             | Whether newer messages are loading as the user scrolls down. Used internally by `VirtualizedMessageList`.                                                                                                 | `boolean`                                                         |
| `members`                      | Members of this channel. Members are permanent; watchers are currently online.                                                                                                                            | `Record<string, ChannelMemberResponse>`                           |
| `messages`                     | Array of [message objects](/chat/docs/javascript/send-message/).                                                                                                                                          | `LocalMessage[]`                                                  |
| `mutes`                        | Array of muted users for the current channel.                                                                                                                                                             | `Mute[]`                                                          |
| `notifications`                | Temporary notifications added to `MessageList` on specific actions.                                                                                                                                       | `{id: string, text: string, type: 'success' \| 'error'}[]`        |
| `onLinkPreviewDismissed`       | Custom function to react to link preview dismissal. See the guide [Link Previews in Message Composer](/chat/docs/sdk/react/guides/customization/link-previews/) for more.                                 | `(linkPreview: LinkPreview) => void`                              |
| `pinnedMessages`               | Messages that are pinned in the channel.                                                                                                                                                                  | `LocalMessage[]`                                                  |
| `read`                         | Read state for each channel member.                                                                                                                                                                       | `Record<string, ChannelReadState>`                                |
| `shouldGenerateVideoThumbnail` | Forwarded from the `Channel` component [prop `shouldGenerateVideoThumbnail`](/chat/docs/sdk/react/components/core-components/channel#shouldgeneratevideothumbnail/).                                      | `boolean`                                                         |
| `suppressAutoscroll`           | Whether auto-scroll to bottom is suppressed. Used by `MessageList` and `VirtualizedMessageList`.                                                                                                          | `boolean`                                                         |
| `thread`                       | Parent message for a thread, if there is one. Otherwise `null`.                                                                                                                                           | `LocalMessage \| null`                                            |
| `threadHasMore`                | Whether there are more messages available in the active thread.                                                                                                                                           | `boolean`                                                         |
| `threadLoadingMore`            | Whether the thread is currently loading more messages.                                                                                                                                                    | `boolean`                                                         |
| `threadMessages`               | Array of messages within a thread.                                                                                                                                                                        | `LocalMessage[]`                                                  |
| `threadSuppressAutoscroll`     | Whether scrolling to the bottom is prevented in the thread. Used internally by `MessageList` and `VirtualizedMessageList`.                                                                                | `boolean`                                                         |
| `videoAttachmentSizeHandler`   | Forwarded from the `Channel` component [prop `videoAttachmentSizeHandler`](/chat/docs/sdk/react/components/core-components/channel#videoattachmentsizehandler/).                                          | `(a: Attachment, e: HTMLElement) => VideoAttachmentConfiguration` |
| `watcher_count`                | Legacy snake-case watcher count from channel state.                                                                                                                                                       | `number`                                                          |
| `watcherCount`                 | The number of watchers on the channel.                                                                                                                                                                    | `number`                                                          |
| `watchers`                     | Users who are currently watching the channel.                                                                                                                                                             | `Record<string, UserResponse>`                                    |


---

This page was last updated at 2026-05-22T16:32:13.400Z.

For the most recent version of this documentation, visit [https://getstream.io/chat/docs/sdk/react/components/contexts/channel-state-context/](https://getstream.io/chat/docs/sdk/react/components/contexts/channel-state-context/).