GitHub

Source

useParticipants

The useParticipants hook returns all participants (local and remote) of the current room.

Import

import { useParticipants } from "@livekit/components-react";

Remarks

To optimize performance, you can use the updateOnlyOn property to decide on what RoomEvents the hook updates.

Usage

const participants = useParticipants();
<ParticipantLoop participants={participants}>
<ParticipantName />
</ParticipantLoop>;

Properties

options.roomRoomOptional

The room to use. If not provided, the hook will use the room from the context.

options.updateOnlyOnRoomEvent[]Optional

To optimize performance, you can use the updateOnlyOn property to decide on what RoomEvents the hook updates. By default it updates on all relevant RoomEvents to keep the returned participants array up to date. The minimal set of non-overwriteable RoomEvents is: [RoomEvent.ParticipantConnected, RoomEvent.ParticipantDisconnected, RoomEvent.ConnectionStateChanged]

Returns

(import('livekit-client').RemoteParticipant | import('livekit-client').LocalParticipant)[]