Highlight whoever is talking with useActiveSpeakerId and build volume meters with useAudioLevelObserver.
Showing who is speaking makes a call feel alive. Daily React gives you two tools: useActiveSpeakerId for the current speaker, and useAudioLevelObserver for continuous volume.
The active speaker is a coarse, on/off signal. For a continuous volume meter, useAudioLevelObserver calls you back with a number between 0 and 1 as a participant’s volume changes:
import { useAudioLevelObserver, useLocalSessionId } from '@daily-co/daily-react';import { useCallback, useRef } from 'react';function MicMeter() { const localSessionId = useLocalSessionId(); const barRef = useRef(null); useAudioLevelObserver( localSessionId, useCallback((volume) => { // Drive the DOM directly; avoid setState on every frame. if (barRef.current) barRef.current.style.transform = `scaleY(${Math.max(0.05, volume)})`; }, []) ); return <div ref={barRef} style={{ height: 40, width: 8, background: 'limegreen', transformOrigin: 'bottom' }} />;}
Volume fires frequently. Write to a ref and mutate the DOM (as above) rather than calling setState on every change, which would re-render the component dozens of times a second. The callback must be memoized with useCallback, like all Daily React event callbacks.
Pass interval (minimum 100ms) to control how often the callback fires, and onError to handle browsers where the observer is unavailable.
The older useAudioLevel hook (which took a raw MediaStreamTrack) is deprecated as of 0.20.0. Use useAudioLevelObserver with a sessionId instead.