---
source_url: https://www.pubnub.com/docs/chat/chat-sdk/build/features/channels/leave
title: Leave channels
updated_at: 2026-06-12T11:22:28.846Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Leave channels

:::note Requires App Context
Enable [App Context](https://youtu.be/9UEoSlngpYI) for your keyset in the [Admin Portal](https://admin.pubnub.com/).
:::

Remove a user's channel membership with `leave()`.

## Interactive demo

Sample React app demonstrating user-channel [membership](https://www.pubnub.com/docs/chat/chat-sdk/build/features/channels/membership).

:::tip Want to implement something similar?
[Implementation guide](https://www.pubnub.com/how-to/chat-sdk-manage-user-channel-membership/) | [Source code](https://github.com/PubNubDevelopers/Chat-SDK-How-Tos/tree/main/membership)
:::

### Test it out

Choose whether you want to [join](https://www.pubnub.com/docs/chat/chat-sdk/build/features/channels/join) or leave a given channel and wait until you [get notified](https://www.pubnub.com/docs/chat/chat-sdk/build/features/channels/membership#get-updates) when that happens.

## Method signature

##### Under the hood

`leave()` calls App Context API and the JavaScript SDK [removeMemberships()](https://www.pubnub.com/docs/sdks/javascript/api-reference/objects#remove-channel-memberships) method.

This method has the following signature:

```ts
channel.leave(): Promise<true | error>
```

### Input

This method doesn't take any parameters.

### Output

| Type | Description |
| --- | --- |
| `Promise<true>` or `Promise<Error>` | Promise returned for leaving the channel successfully, or an error. |

## Sample code

Leave the `support` channel.

```ts
// reference the "channel" object
const channel = await chat.getChannel("support")
// you must be a member of the "support" channel...
await channel.join({ custom: { support_plan: "premium" } })
// ...to leave it
await channel.leave()
```