Overview of LiveKit Meet
main@livekit/components-react library for its UI components, powered by LiveKit Cloud for real-time media transport.repository·main·Indexed 21 days ago
https://github.com/livekit-examples/meetAn open-source video conferencing reference implementation built with Next.js and the @livekit/components-react library. It demonstrates real-time communication tools using LiveKit Cloud, featuring implementations for background effects, Krisp noise cancellation, End-to-End Encryption (E2EE), and CPU performance optimization.
@livekit/components-react library for its UI components, powered by LiveKit Cloud for real-time media transport.The project uses the following core technologies:
create-next-app)Follow these steps to get a local development environment running:
pnpm to install the required packages..env.example file to .env.local and populate the required values.pnpm install
cp .env.example .env.local
# Update .env.local with your credentials
pnpm devThe DebugMode component includes a mechanism to call room.simulateScenario(value). This is useful for testing how your application handles various connectivity and signaling events.
Available scenarios are passed via the handleSimulate function in the UI, which maps to the underlying LiveKit simulateScenario method. One example provided in the implementation is signal-reconnect.
The isMeetStaging function returns true if the application is currently running on the meet.staging.livekit.io host. This is useful for toggling staging-specific configurations or debugging tools.
if (isMeetStaging()) {
console.log('Running in staging environment');
}The isLowPowerDevice function returns a boolean indicating if the current device is likely a low-power device. It determines this by checking if navigator.hardwareConcurrency is less than 6. This can be used to adjust media quality or feature sets to preserve device performance.
if (isLowPowerDevice()) {
// Disable heavy visual effects or reduce video resolution
}When using the useKrispNoiseFilter hook (which powers the noise cancellation in MicrophoneSettings), you can pass a filterOptions object to tune performance and behavior:
bufferOverflowMs: Milliseconds before buffer overflow triggers.bufferDropMs: Milliseconds for buffer drop handling.quality: Set to 'low' for low-power devices or 'medium' for standard devices.onBufferDrop: A callback function executed when a buffer drop occurs. Note that in Krisp versions >= 0.3.2, the filter will automatically disable itself if a buffer drop occurs.const { isNoiseFilterEnabled, setNoiseFilterEnabled, isNoiseFilterPending } = useKrispNoiseFilter({
filterOptions: {
bufferOverflowMs: 100,
bufferDropMs: 200,
quality: 'medium',
onBufferDrop: () => {
console.warn('krisp buffer dropped');
},
},
});The generateRoomId function creates a unique identifier for a meeting room in the format xxxx-xxxx, where x is a random alphanumeric character. This is suitable for generating quick, shareable room links.
const roomId = generateRoomId(); // e.g., "a1b2-c3d4"Use encodePassphrase and decodePassphrase to handle passphrases in a URL-safe format using URI encoding. This is useful for passing passphrases as part of a URL query parameter.
const encoded = encodePassphrase('my secret passphrase');
const decoded = decodePassphrase(encoded);The useDebugMode hook configures the LiveKit client logging level and integrates with Datadog for error and log tracking if the necessary environment variables are present. It also attaches the current room instance to window.__lk_room for manual inspection in the browser console.
To use it, call the hook within a component that has access to the LiveKit RoomContext (e.g., inside a <LiveKitRoom> provider).
Environment Variables for Datadog Integration:
NEXT_PUBLIC_DATADOG_CLIENT_TOKENNEXT_PUBLIC_DATADOG_SITEimport { useDebugMode } from './Debug';
import { LogLevel } from 'livekit-client';
// Inside a component wrapped by LiveKitRoom
useDebugMode({ logLevel: LogLevel.debug });The SettingsMenu component provides a tabbed interface for managing media devices (camera, microphone, speaker) and controlling room recording.
CameraSettings, MicrophoneSettings, and MediaDeviceMenu for audio output selection.useRoomContext and useIsRecording from @livekit/components-react to sync with the current room state.To enable the recording tab, you must provide the NEXT_PUBLIC_LK_RECORD_ENDPOINT environment variable. If this variable is missing, the recording tab will not be rendered.
fetch requests to {endpoint}/start?roomName={roomName} or {endpoint}/stop?roomName={roomName}.room.isE2EEEnabled is true.import { SettingsMenu } from './lib/SettingsMenu';
// Usage within a LiveKit layout
<SettingsMenu />The useLowCPUOptimizer hook monitors the local participant's CPU usage. When the ParticipantEvent.LocalTrackCpuConstrained event is triggered, the hook enters a 'low power mode' and applies optimization strategies to reduce CPU load.
It accepts a room instance and an optional options object to configure how the optimizer behaves when constraints are detected.
Optimization Strategies:
reducePublisherVideoQuality is true, it calls track.prioritizePerformance() on the constrained local track.disableVideoProcessing is true, it calls track.stopProcessor() on the constrained track.reduceSubscriberVideoQuality is true, it sets the video quality of all existing remote track publications to VideoQuality.LOW. Additionally, any new tracks subscribed to while in low power mode will automatically be set to VideoQuality.LOW.import { useLowCPUOptimizer } from './lib/usePerfomanceOptimiser';
// Inside your component
const lowPowerMode = useLowCPUOptimizer(room, {
reducePublisherVideoQuality: true,
reduceSubscriberVideoQuality: true,
disableVideoProcessing: false,
});
if (lowPowerMode) {
console.log('Device is in low power mode due to CPU constraints');
}