Quick Start
The following code snippets show a basic example of using the core sdk to join and leave a room.
Create client
import { WherebyClient } from "@whereby.com/core";
const client = new WherebyClient();
const roomConnection = client.getRoomConnection();
const localMedia = client.getLocalMedia();Join room
type JoinRoomOptions = {
roomUrl: string;
audio?: boolean;
video?: boolean;
}
async function joinRoom({roomUrl, audio = false, video = false}: JoinRoomOptions) {
/** If sending media, you need to start local media before initialising, for example:
async function startLocalMedia(stream: MediaStream) {
await localMedia.startMedia(stream);
}
**/
roomConnection.initialize({
localMediaOptions: {
audio,
video,
},
roomUrl,
});
try {
await roomConnection.joinRoom();
} catch(error) {
console.error("Could not join room", error);
return;
}
}Subscribe to remote participants
Minimal sample: Join for 10 seconds and then leave
This demonstrates the most basic functionality of the library. From this example, you can go on to implement more advanced functionality that is explained in more detail in the next sections of the documentation:
Last updated
Was this helpful?

