GitHub

Source

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]);

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 }
]);

Properties

sourcesTOptional

Returns

UseTracksHookReturnType<T>;