Skip to content

Join a room

Joining a room is how a user becomes an active participant: it registers their presence, returns the room’s current state, and hands you the cursor you’ll use to stream new events.

You need an authenticated user first — see authentication models. The join call itself is the same regardless of which model minted the session.

join.js — sportstalk-sdk
import { ChatClient } from 'sportstalk-sdk';
// Public app id only. userToken comes from whichever auth model you chose.
const client = ChatClient.init({ appId: APP_ID });
client.setUserToken(userToken);
// Tell the SDK who's joining — the server rejects an end-user token whose
// asserted identity doesn't match the userid in the join request.
client.setUser({ userid: 'u-8842', handle: 'dave_m', displayname: 'Dave' });
// live-event-chat is a custom ID chosen by your application.
const { room } = await client.joinRoomByCustomId('live-event-chat');
console.log('TalkLabs room ID:', room.id);

The response includes the room, the participant count, and an events cursor. Hold onto that cursor — it’s the starting point for listening for events.