Skip to main content

Connected Users

The collab client comes with getting connected users support. You can get connected users in the loaded document with their id and the current page number.

In order to get connected users, you must turn on enableConnectedUsers in the client constructor:

const client = new CollabClient({
...otherOptions,
enableConnectedUsers: true
})

getConnectedUsers#

note

You must load a document before getting connected users. You can find how to load document here: Loading documents

To get connected users, you can use the getConnectedUsers(documentId) function:

type ConnectedUser = {
userId: string
currentPage: number;
};
client.getConnectedUsers(documentId: string): Promise<ConnectedUser[]>

The current document id can be retrieved with client.getDocumentId(). It returns a Promise of an array of connected users include userId and currentPage number.

Connected users changed event#

You can also subscribe to the connectedUsersChanged event to get notified when connected users page number changed or becomes online/offline.