Quickstart
This quickstart shows how to use Dyte's core SDKs to add live video and audio to your JavaScript based applications.
Objective
You'll learn how to:
- Install the Dyte SDK
- Initialize Dyte Client
- Connect to the meeting
- Go live!
Before Getting Started
-
Make sure you've read the Getting Started with Dyte topic and completed the following steps:
- Create a Dyte Developer Account
- Create a Dyte Meeting
- Add Participant to the meeting
Step 1: Install the SDK
You can install the package using CDN, npm or Yarn.
- npm
- yarn
- CDN
Step 2: Initialize the SDK
- Initialize the Dyte client.
- Call the
init()
method and pass the authToken.
authToken | After you've created the meeting, add each participant to the meeting using the Add Participant API. The API response contains the authToken. |
const meeting = await DyteClient.init({
authToken,
});
Step 3: Connect to the meeting
Now, you have established the connection with the Dyte meeting server successfully. Next step is to join the room.
Join the room
To join the meeting room, call join() method on the DyteClient instance as shown below.
await meeting.join();
Once the join room process completes roomJoined event is emitted on meeting.self namespace.
If you want to perform any actions, such as enabling audio, video, or starting and stopping recording, you can do so after the roomJoined event is fired.
For example:
meeting.self.on('roomJoined', () => {
console.log('User has joined the room', meeting.self.roomJoined);
// run my actions.
});
await meeting.join();
Leave the room
Once the meeting is over, you can leave the meeting room.
To leave the meeting room, call leaveRoom()
method on the dyteClient as shown
below.
await meeting.leaveRoom();