Docs
React SDK

useParticipants

Read a reactive list of local and remote participants.

Import

React
import { useParticipants } from '@relayrtc/react'

Requirements

Call this hook inside RelayProvider, in a React function component or custom hook. A joined room is needed for live data and actions.

Returns

FieldTypeMeaning
Return valuereadonly RelayParticipant[]Participant views with id, name, metadata and identity fields.

Example

React
const participants = useParticipants({ includeLocal: false })
 
return participants.map((person) => (
  <p key={person.id}>{person.name}</p>
))

Options and behavior

includeLocal defaults to true. With false, only remote participants are returned. Remote participants also expose a tracks map. The list is empty before joining.