Unsubscribes and removes Realtime channel from Realtime client.
Removing a channel is a great way to maintain the performance of your project's Realtime service as well as your database if you're listening to Postgres changes.
Supabase will automatically handle cleanup 30 seconds after a client is disconnected, but unused channels may cause degradation as more clients are simultaneously subscribed.
If you removed all channels, the client automatically disconnects from the Realtime websocket. This can be disabled in the Realtime config by setting disconnectOnNoSubscriptions to false.
Examples
Remove a channel
let channel = await supabase.channel("channelId")
//...
await supabase.removeChannel(channel)
Unsubscribe from a channel
let channel = await supabase.channel("channelId")
//...
await channel.unsubscribe()