You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

livekit-client

Package Overview
Dependencies
Maintainers
29
Versions
271
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

livekit-client

JavaScript/TypeScript client SDK for LiveKit

2.9.8
Source
npmnpm
Version published
Weekly downloads
155K
-17.81%
Maintainers
29
Weekly downloads
 
Created

What is livekit-client?

The livekit-client npm package is a JavaScript client library for LiveKit, a platform that provides scalable WebRTC infrastructure for real-time audio and video communication. It allows developers to build applications with features like video conferencing, live streaming, and real-time data transmission.

What are livekit-client's main functionalities?

Connecting to a Room

This feature allows you to connect to a LiveKit room using a WebSocket URL and an access token. The code sample demonstrates how to establish a connection to a room, which is the first step in setting up a real-time communication session.

const { connect } = require('livekit-client');

async function joinRoom() {
  const room = await connect('ws://your-livekit-server', 'your-access-token');
  console.log('Connected to room', room.name);
}

joinRoom();

Publishing Local Tracks

This feature allows you to publish local audio and video tracks to a LiveKit room. The code sample shows how to create local media tracks and publish them, enabling other participants in the room to receive the media streams.

const { createLocalTracks } = require('livekit-client');

async function publishTracks(room) {
  const tracks = await createLocalTracks({ audio: true, video: true });
  tracks.forEach(track => room.localParticipant.publishTrack(track));
  console.log('Published local tracks');
}

// Assume room is already connected
publishTracks(room);

Subscribing to Remote Tracks

This feature allows you to subscribe to remote tracks published by other participants in the room. The code sample demonstrates how to handle the 'trackSubscribed' event to receive and play remote media streams.

room.on('trackSubscribed', (track, publication, participant) => {
  console.log('Subscribed to track', track.sid);
  // Attach track to a video element
  const videoElement = document.createElement('video');
  videoElement.srcObject = new MediaStream([track.mediaStreamTrack]);
  document.body.appendChild(videoElement);
  videoElement.play();
});

Other packages similar to livekit-client

FAQs

Package last updated on 16 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts