Leave channels

Requires App Context

To set up and manage channel membership, you must enable App Context for your app's keyset in the Admin Portal.

Use the leave() method to remove user's channel membership.

Interactive demo

Check how a sample implementation could look like in a React app showcasing user-channel membership.

Want to implement something similar?

Read how to do that or go straight to the demo's source code.

Test it out

Choose whether you want to join or leave a given channel and wait until you get notified when that happens.

Method signature

icon

Under the hood


This method has the following signature:

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

Input

This method doesn't take any parameters.

Output

TypeDescription
Promise<true> or Promise<Error>
Promise returned for leaving the channel successfully, or an error.

Sample code

Leave the support channel.

1// reference the "channel" object
2const channel = await chat.getChannel("support")
3// you must be a member of the "support" channel...
4await channel.join(
5 (data) => {
6 console.log(
7 "This is my first message on this channel! Nice to meet you all!", data
8 )
9 },
10 {
11 custom: {support_plan: "premium"}
12 }
13)
14// ...to leave it
15await channel.leave()
Last updated on