From listeners to hooks
With plaindaily-js, a call is a stream of events. You keep your own copy of call state and update it as events arrive:
useParticipantIds re-renders.
Hooks are selectors
Under the hood, Daily React stores call state in Jotai atoms and updates them asdaily-js events fire. Each hook is a selector: it reads one slice of that store and subscribes your component to changes in that slice only.
This is the single most important thing to internalize, because it drives both correctness and performance. Two hooks that read different slices re-render independently:
useParticipantIdsre-renders when the set of participants changes, not when one participant mutes.useParticipantProperty(id, 'user_name')re-renders when that one participant’s name changes, and ignores everything else.
Read the smallest slice you need
Prefer the narrow hook over the broad one. Reading a whole participant object re-renders your component on every property change; reading a single property does not.The object-returning hooks
useParticipant, useLocalParticipant, and useActiveParticipant are deprecated as of 0.17.0 in favor of the property-and-ID hooks above, precisely because returning whole objects causes broad re-renders. New code should use the narrow hooks.Events become hook callbacks
You rarely calluseDailyEvent directly, because most events already have a hook that exposes their state and an optional callback. Reach for the feature hook first:
Drop down to
useDailyEvent only for events without a dedicated hook. See Handling events for the rules.
Components own the DOM
Hooks give you state; two things in a call need to touch the DOM directly, and those are components:DailyVideoattaches a participant’s video track to a<video>element.DailyAudioplays remote audio, managing speaker slots and autoplay.
<DailyVideo> elements and never imperatively call el.srcObject = .... See Rendering media.
The escape hatch
Daily React does not wrap everydaily-js method. When you need one that has no dedicated hook, get the call object with useDaily and call it directly:
useDaily returns the exact same DailyCall instance you would get from daily-js, so anything in the daily-js reference works here. The difference is that imperative calls do not re-render anything by themselves; the resulting events flow back through the store and re-render the hooks that read the affected state.
Putting it together
A Daily React component, in one breath: read the state you need with the narrowest hooks, render media with components, and useuseDaily for the imperative actions that have no hook. Everything else, the subscriptions and the cleanup, is handled for you.
Next steps
The call object and provider
Creating, joining, and leaving.
Working with participants
The hooks that read participant state.
Handling events
When and how to use the event hooks.
Rendering media
Video and audio components.