/ SDKs / JavaScript
SDKs
Chat SDKs JavaScript v4
Chat SDKs JavaScript
Chat SDKs
JavaScript
Version 4

Retrieve a channel by URL

Copy link

Since a channel URL is a unique identifier of a channel, you can use it when retrieving a channel object.

Open channel

Copy link
JavaScriptTypeScript
const channel = await sb.openChannel.getChannel(CHANNEL_URL);

Group channel

Copy link
JavaScriptTypeScript
const channel = await sb.groupChannel.getChannel(CHANNEL_URL);

We recommend that you store a user's channel URLs to handle the lifecycle or state changes of your app as well as any other unexpected situations. For example, when a user is disconnected from the Sendbird server by temporarily switching to another app, you can provide a smooth restoration of the user's state once the user has returned to your app by using the stored URL to fetch the appropriate channel instance.