Skip to main content

User sessions

When loading your application, you might want to check if the user already has a session.

To do so, you can use the getUserSession API

getUserSession(options): Promise<User | null>#

  • options (object)
    • signInIfExists (boolean) If set, the user will be automatically signed in if they have a session

Returns null if no session exists, or an object with id, userName and token if it does exist.


This API also works for anonymous users


const client = new CollabClient({ ... });
const checkLogin = async () => {
const user = await client.getUserSession({ signInIfExists: true });
if(user) {
window.location.href = `/profile/${}`;
} else {
window.location.href = '/login';