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();Value
banChannelMembers
Can ban/block channel members.
| Type |
|---|
| boolean |
deleteAnyMessage
Can delete any message in the channel.
| Type |
|---|
| boolean |
deleteOwnMessage
Can delete own messages in the channel.
| Type |
|---|
| boolean |
flagMessage
Can flag a message.
| Type |
|---|
| boolean |
pinMessage
Can pin a message.
| Type |
|---|
| boolean |
quoteMessage
Can quote a message.
| Type |
|---|
| boolean |
readEvents
Can receive read events.
| Type |
|---|
| boolean |
sendLinks
Can attach links to messages.
| Type |
|---|
| boolean |
sendMessage
Can send messages.
| Type |
|---|
| boolean |
sendReaction
Can send reactions.
| Type |
|---|
| boolean |
sendReply
Can reply to a message.
| Type |
|---|
| boolean |
sendTypingEvents
Can send typing events.
| Type |
|---|
| boolean |
updateAnyMessage
Can update any message in the channel.
| Type |
|---|
| boolean |
updateOwnMessage
Can update own messages in the channel.
| Type |
|---|
| boolean |
uploadFile
Can upload message attachments.
| Type |
|---|
| boolean |
sendPoll
Can send polls as messages.
| Type |
|---|
| boolean |
queryPollVotes
Can query poll votes.
| Type |
|---|
| boolean |
castPollVote
Can cast poll votes.
| Type |
|---|
| boolean |