Chat / JavaScript
Chat JavaScript v4
Chat JavaScript
Chat
JavaScript
Home
/
Chat
/
JavaScript
/
User
This is the new Docs for Chat SDK v4 for JavaScript. To see the previous Docs, click here.

Retrieve the online status of a user

You can check if a user in the Sendbird application is currently connected to the Sendbird server. For group channels only, you can check whether each member is currently connected to the server.

const queryParams: ApplicationUserListQueryParams = {
    userIdsFilter: ['Jeff'],
};
const query = sb.createApplicationUserListQuery(queryParams);

const [jeff] = await query.next();
if (jeff.connectionStatus === UserOnlineState.ONLINE) {
    // Jeff is currently online.
    // Acceptable values for User.connectionStatus are NON_AVAILABLE, ONLINE, and OFFLINE.
    // ...
}

Retrieve the online status of channel members

In a group channel, you can check the current connection status of each member. To do so, you need to first call the refresh() method to update the channel with the latest information, then call members to retrieve a list of channel members.

When the members property returns a list of all members, you can call user.connectionStatus for each User object in the list to check the corresponding member's current online status. Acceptable values of the connectionStatus property are offline and online.

Connection status values

ValueDescription

offline

The user isn't connected to the Sendbird server.

online

The user is connected to the Sendbird server.