import { useContext } from "react";
import { OwnCapabilitiesContext } from "stream-chat-react-native";
const { uploadFile, updateAnyMessage, deleteAnyMessage } = useContext(
OwnCapabilitiesContext,
);OwnCapabilitiesContext
OwnCapabilitiesContext is provided by Channel. It exposes the current user's capabilities on the channel. For details, see: /chat/docs/javascript/chat_permission_policies/
If you are not familiar with the React Context API, see the React docs.
Best Practices
- Use
useOwnCapabilitiesContextto gate UI actions consistently. - Hide or disable controls when capabilities are false to avoid invalid actions.
- Treat capabilities as read-only; change permissions via server configuration.
- Re-check capabilities when channel membership changes.
- Keep capability checks close to the UI elements they govern.
Basic Usage
Consume OwnCapabilitiesContext in any child of Channel:
Alternatively, use the useOwnCapabilitiesContext hook.
import { useOwnCapabilitiesContext } from "stream-chat-react-native";
const { uploadFile, updateAnyMessage, deleteAnyMessage } =
useOwnCapabilitiesContext();Values
| Value | Description | Type |
|---|---|---|
banChannelMembers | Can ban/block channel members. | boolean |
castPollVote | Can cast poll votes. | boolean |
deleteAnyMessage | Can delete any message in the channel. | boolean |
deleteOwnMessage | Can delete own messages in the channel. | boolean |
flagMessage | Can flag a message. | boolean |
pinMessage | Can pin a message. | boolean |
queryPollVotes | Can query poll votes. | boolean |
quoteMessage | Can quote a message. | boolean |
readEvents | Can receive read events. | boolean |
sendLinks | Can attach links to messages. | boolean |
sendMessage | Can send messages. | boolean |
sendPoll | Can send polls as messages. | boolean |
sendReaction | Can send reactions. | boolean |
sendReply | Can reply to a message. | boolean |
sendTypingEvents | Can send typing events. | boolean |
updateAnyMessage | Can update any message in the channel. | boolean |
updateOwnMessage | Can update own messages in the channel. | boolean |
uploadFile | Can upload message attachments. | boolean |