import { useChannelActionItems } from "stream-chat-react-native";
const actionItems = useChannelActionItems({
channel,
getChannelActionItems: ({ defaultItems }) =>
defaultItems.filter((item) => item.id !== "archive"),
});useChannelActionItems
Builds channel action items (mute, archive, leave, delete, etc.) for swipe rows and action sheets.
Best Practices
- Use this hook as the source of truth for channel row actions.
- Prefer
getChannelActionItemsto customize ordering/visibility instead of rebuilding defaults. - Keep custom action handlers async-safe and user-feedback friendly.
- Distinguish direct chats vs group channels when customizing labels.
- Keep destructive actions clearly separated from standard actions.
Usage
Surface-aware customization
Pass surface to indicate which UI is requesting the items. The value flows into context.surface inside your getChannelActionItems override so you can branch per surface, and the default builder uses it to tailor the item set (for example, the default pin/unpin item is excluded when surface is 'details').
import { useChannelActionItems } from "stream-chat-react-native";
const actionItems = useChannelActionItems({
channel,
surface: "details",
getChannelActionItems: ({ defaultItems, context }) =>
context.surface === "details"
? defaultItems.filter((item) => item.id !== "leave")
: defaultItems,
});surface is optional and back-compatible. When omitted, no surface-specific filtering is applied and the hook returns every item the default builder would otherwise produce.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| channel | Channel | Yes | Channel used to compute available actions. |
| surface | ChannelActionSurface ('list' | 'details') | No | Identifies which top-level UI is requesting the items. Forwarded to context.surface inside getChannelActionItems. When omitted, no surface filtering is applied. |
| getChannelActionItems | GetChannelActionItems | No | Optional transformer for default action items. Receives { defaultItems, context }; context.surface reflects the value passed to the hook. |
Returns
| Type | Description |
|---|---|
ChannelActionItem[] | Ordered action definitions for channel UI controls. |