useNotificationTarget

useNotificationTarget returns the panel that the calling component lives in. It inspects React context (ChannelContext, ThreadContext, ThreadsContext, ChannelsContext) and returns the matching panel string. Use it in custom notification UI when you need the panel name; the default snackbar routing uses NotificationTargetProvider for exact host targeting.

Usage

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

const panel = useNotificationTarget();
// → 'channel' | 'thread' | 'channel-list' | 'thread-list' | undefined

Returns

NotificationTargetPanel | undefined. The panel is resolved as follows, in order:

Condition Panel
Mounted inside a Channel with threadList set on ChannelContext 'thread'
Mounted inside a Thread with a threadInstance on ThreadContext 'thread'
Mounted inside a Channel with a channel on ChannelContext 'channel'
Mounted inside a ThreadList with ThreadsContext present 'thread-list'
Mounted inside a ChannelList with ChannelsContext present 'channel-list'
None of the above undefined

The first matching condition wins.

If you need to disambiguate between multiple instances of the same panel (e.g. two thread views on the same screen), wrap the subtree in NotificationTargetProvider with a stable hostId.

Add Chat to my app: getstream.io/SKILL.md

The fastest way to build with Stream. Start a new project or improve an existing one. Full CLI and documentation integration out of the box.


Ask your agent:

/stream Build me a Social App with Feeds and Moderation.
/stream Any livestream calls running?
/stream Chat React Native v9: <Your Question>