useParticipants
function useParticipants(_options?): unknown[];Defined in: packages/react/src/hooks/participant/useParticipants.ts:68
The useParticipants hook returns all participants (local and remote) of the current room.
Parameters
| Parameter | Type |
|---|---|
_options? | UseParticipantsOptions |
Returns
unknown[]
Example
// Basic — render every participant in the current room.
const participants = useParticipants();
<ParticipantLoop participants={participants}><ParticipantName /></ParticipantLoop>;
// Advanced — build a live roster inside the room context.
function Roster() {
const participants = useParticipants();
return <>
<ParticipantLoop participants={participants}>
<ParticipantName />
</ParticipantLoop>
<span>{participants.length} participants</span>
</>;
}
function App() {
return <VoiceRoom agent={agent}><Roster /></VoiceRoom>;
}