LiveKit LogoDocs
Real-timeEgress/IngressCloudReference

useTracks

The useTracks hook returns an array of TrackReference or TrackReferenceOrPlaceholder depending on the provided sources property. If only subscribed tracks are desired, set the onlySubscribed property to true.

Import

import { useTracks } from '@livekit/components-react';

Usage Example 1

// Return all camera track publications.
const trackReferences: TrackReference[] = useTracks([Track.Source.Camera]);

Usage Example 2

// Return all subscribed camera tracks as well as placeholders for
// participants without a camera subscription.
const trackReferencesWithPlaceholders: TrackReferenceOrPlaceholder[] = useTracks([
{ source: Track.Source.Camera, withPlaceholder: true },
]);

Parameters

#
options?UseTracksOptions

Returns

UseTracksHookReturnType<T>;

On this page

ImportUsage Example 1Usage Example 2ParametersReturns

Previous

Chevron IconuseTrackMutedIndicator
LiveKit Logo

Product

SFU

SDKs

Cloud Dashboard

Cloud Status

GitHub Logo