1. Install LiveKit SDK
Install the LiveKit SDK:
yarn add livekit-client
npm install livekit-client --save
2. Join a room
Note that this example hardcodes a token. In a real app, you’ll need your server to generate a token for you.
import { Room } from 'livekit-client';const wsURL = "<wsURL>"const token = "<token>"const room = new Room();await room.connect(wsURL, token);console.log('connected to room', room.name);// publish local camera and mic tracksawait room.localParticipant.enableCameraAndMicrophone();
3. Create a backend server to generate tokens
Set up a server to generate tokens for your app at runtime by following this guide: Generating Tokens.