On this page

Leave channels

Requires App Context

Enable App Context for your keyset in the Admin Portal.

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

Interactive demo

Sample React app demonstrating user-channel membership.

Want to implement something similar?

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