Valora
API Reference@valora-ai/reactindexFunctions

useParticipantAttribute

function useParticipantAttribute(attributeKey, options?): string;

Defined in: packages/react/src/hooks/participant/useParticipantAttribute.ts:40

The useParticipantAttribute hook returns the latest value of a given attribute key of a participant. It requires a Participant object passed as property in the UseParticipantAttributesOptions or via the ParticipantContext.

Parameters

ParameterType
attributeKeystring
options?UseParticipantAttributeOptions

Returns

string

Example

// Basic — read one participant attribute.
const role = useParticipantAttribute("role");

// Advanced — show a participant's role inside a participant tile.
function ParticipantRole({ participant }: { participant: Participant }) {
  const role = useParticipantAttribute("role", { participant });
  const { identity } = useParticipantInfo({ participant });

  return <span>{identity}: {role || "guest"}</span>;
}

function Roster() {
  const participants = useParticipants();
  return <>{participants.map((participant) => <ParticipantRole key={participant.identity} participant={participant} />)}</>;
}

function App() {
  return <VoiceRoom agent={agent}><Roster /></VoiceRoom>;
}

On this page

Valora is local-first

No API key, no server — everything in this doc runs on-device.

Star on GitHub