Docs
React SDK

useLocalParticipant

Read local identity, metadata and media controls.

Import

React
import { useLocalParticipant } 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 valueRoomLocalParticipant or nullLocal participant when joined.

Example

React
const local = useLocalParticipant()
 
return (
  <button disabled={!local} onClick={() => void local?.camera.enable().catch(console.error)}>
    Enable camera
  </button>
)

Options and behavior

The participant exposes microphone, camera, screen, devices and permissions, plus updateMetadata(metadata). Metadata updates require metadata:update and replace the object.