# OwnCapabilitiesContext

> **Info:** This is release candidate documentation for **Stream Chat React Native SDK v10**. For the latest stable version, see the [latest version (v9)](https://getstream.io/chat/docs/sdk/react-native/).

`OwnCapabilitiesContext` tells the components inside [`Channel`](https://getstream.io/chat/docs/sdk/react-native/v10/component-reference/channel/channel/) or `Thread` what the current user may do in the channel, as one boolean for each capability. The SDK's components read it to decide what to show, such as which message actions are in the menu. Read it with `useOwnCapabilitiesContext()`.

The values come from the channel's `own_capabilities`, which the server sends with the channel and which follow `capabilities.changed` events. They depend on the user's role, the channel type and the channel's settings. See [What channels and threads hold](https://getstream.io/chat/docs/sdk/react-native/v10/state/channels-and-threads/what-channels-and-threads-hold/#capabilities).

## Best practices

- Check a capability before showing a control for an action, so the user doesn't get an error from the server.
- Use `overrideOwnCapabilities` on `Channel` and `Thread` to hide a control the user's capabilities would show, or to show one they would hide. It changes only what the SDK's UI shows: the server still checks the user's permissions.
- Call `useOwnCapabilitiesContext()` only inside `Channel` or `Thread`. It throws anywhere else. For a channel outside them, `useChannelOwnCapabilities(channel)` returns the raw `own_capabilities` list.

## Basic usage

```tsx title="src/PinButton.tsx"
import { Button } from "react-native";
import type { LocalMessage } from "stream-chat";
import {
  useChannel,
  useOwnCapabilitiesContext,
} from "stream-chat-react-native";

export const PinButton = ({ message }: { message: LocalMessage }) => {
  const channel = useChannel();
  const { pinMessage } = useOwnCapabilitiesContext();

  if (!pinMessage) return null;

  return (
    <Button
      onPress={() => void channel.getClient().pinMessage({ id: message.id })}
      title="Pin"
    />
  );
};
```

To change a capability for the SDK's UI, pass `overrideOwnCapabilities`. This channel shows no reaction picker and no voting buttons, whatever the user's role:

```tsx title="src/ReadOnlyReactionsChannel.tsx"
import type { PropsWithChildren } from "react";
import type { Channel as StreamChannel } from "stream-chat";
import { Channel } from "stream-chat-react-native";
import type { OwnCapabilitiesContextValue } from "stream-chat-react-native";

const capabilityOverrides: Partial<OwnCapabilitiesContextValue> = {
  castPollVote: false,
  sendReaction: false,
};

export const ReadOnlyReactionsChannel = ({
  channel,
  children,
}: PropsWithChildren<{ channel: StreamChannel }>) => (
  <Channel
    channel={channel}
    keyboardVerticalOffset={0}
    overrideOwnCapabilities={capabilityOverrides}
  >
    {children}
  </Channel>
);
```

A key you leave out keeps the value from the server. The context is rebuilt when the channel's capabilities change, or when the contents of `overrideOwnCapabilities` do; a new object with the same values doesn't rebuild it.

## Values

Every value is a `boolean`, `true` when the channel's `own_capabilities` include the capability in the second column. The type is `OwnCapabilitiesContextValue`, which is `Record<OwnCapability, boolean>`.

| Value                  | Type      | Capability               | What the SDK uses it for                                                                                                      |
| ---------------------- | --------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| `banChannelMembers`    | `boolean` | `ban-channel-members`    | The Ban User action, on other users' messages                                                                                 |
| `castPollVote`         | `boolean` | `cast-poll-vote`         | The voting buttons of a poll's options, while the poll is open                                                                |
| `deleteAnyMessage`     | `boolean` | `delete-any-message`     | The Delete Message action, on other users' messages                                                                           |
| `deleteOwnMessage`     | `boolean` | `delete-own-message`     | The Delete Message action, on the user's own messages                                                                         |
| `flagMessage`          | `boolean` | `flag-message`           | The Flag Message action, on other users' messages                                                                             |
| `pinMessage`           | `boolean` | `pin-message`            | The Pin to Conversation and Unpin from Conversation actions                                                                   |
| `queryPollVotes`       | `boolean` | `query-poll-votes`       | The "Show All" button of an option with more than five votes in a poll's results                                              |
| `quoteMessage`         | `boolean` | `quote-message`          | The Reply action, outside threads                                                                                             |
| `readEvents`           | `boolean` | `read-events`            | The Mark as Unread action on other users' messages, and the unread messages notification in the message list                  |
| `sendLinks`            | `boolean` | `send-links`             | Without it, the composer refuses to send a message with a link and shows an alert                                             |
| `sendMessage`          | `boolean` | `send-message`           | Without it, the composer renders `SendMessageDisallowedIndicator` in place of the input, unless the user is editing a message |
| `sendPoll`             | `boolean` | `send-poll`              | The poll button of the attachment picker                                                                                      |
| `sendReaction`         | `boolean` | `send-reaction`          | The reaction picker in the message menu, and reacting from a message's reactions                                              |
| `sendReply`            | `boolean` | `send-reply`             | The Thread Reply action, outside threads                                                                                      |
| `sendTypingEvents`     | `boolean` | `send-typing-events`     | No SDK component reads it                                                                                                     |
| `updateAnyMessage`     | `boolean` | `update-any-message`     | The Edit Message action, on other users' messages                                                                             |
| `updateChannelMembers` | `boolean` | `update-channel-members` | No SDK component reads it                                                                                                     |
| `updateOwnMessage`     | `boolean` | `update-own-message`     | The Edit Message action, on the user's own messages                                                                           |
| `uploadFile`           | `boolean` | `upload-file`            | The attach button of the composer                                                                                             |

`allOwnCapabilities` maps each key to its capability string, and `OwnCapability` is the union of the keys. Both are exported.

The menu's actions have other conditions too, such as whether the message failed to send. [Message actions](https://getstream.io/chat/docs/sdk/react-native/v10/ui/customizing/actions/#what-the-default-list-holds) lists them.

## Related hooks

- `useOwnCapabilitiesContext()` returns the value above, and throws outside `Channel` and `Thread`.
- `useChannelOwnCapabilities(channel)` returns the channel's `own_capabilities` from `channel.state`, for any channel. It doesn't apply `overrideOwnCapabilities`.

---

For the most recent version of this documentation, visit [https://getstream.io/chat/docs/sdk/react-native/v10/component-reference/channel/owncapabilitiescontext/](https://getstream.io/chat/docs/sdk/react-native/v10/component-reference/channel/owncapabilitiescontext/).