---
source_url: https://www.pubnub.com/docs/chat/chat-sdk/build/features/channels/leave
title: Leave channels
description: Learn how to use the leave() method with PubNub Chat SDK to unsubscribe from channels and manage channel memberships.
updated_at: 2026-05-12T11:37:48.000Z
---

# Leave channels

> For AI agents: documentation index at https://www.pubnub.com/llms-full.txt

:::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.md).

:::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.md) or leave a given channel and wait until you [get notified](https://www.pubnub.com/docs/chat/chat-sdk/build/features/channels/membership.md#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.md#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()
```

Last updated at: 2026-05-12T11:37:48.000Z
