Skip to main content
In Daily React you rarely subscribe to events directly, because most call state already has a hook. When you do need a raw event, useDailyEvent and useThrottledDailyEvent register and tear down listeners for you.

Reach for a hook first

Before subscribing to an event, check whether a hook already exposes the state it carries. The hooks keep the state for you and re-render on change, which is usually what you actually want: Many of these hooks also accept the corresponding on... callback, so you can run side effects on the event while still getting the reactive state.

Subscribe with useDailyEvent

For events without a dedicated hook, useDailyEvent registers a listener and removes it when the component unmounts:

The callback must be memoized

This is the one rule that trips people up. The callback you pass must be a stable reference, normally wrapped in useCallback:
Passing a fresh function each render makes the hook resubscribe on every render, which can trigger a console error about a potential re-render loop. Always memoize the callback, and list its real dependencies in the useCallback array.

Batch high-frequency events

Some events fire in bursts, for example a wave of participant-joined events when a large call starts. useThrottledDailyEvent collects events over a window and hands you an array of everything that happened, so you update state once instead of once per event:
The default throttle window is 100ms; pass throttleTimeout to change it. The same memoized-callback rule applies. Note that the callback receives an array, unlike useDailyEvent, which receives a single event.

Choosing between them

  • One-off or low-frequency event, react immediately: useDailyEvent.
  • Bursty or high-frequency event where you only need the net result: useThrottledDailyEvent.
  • The event maps to call state you want to render: use the dedicated hook from the table above.

Next steps

Custom messages

Send and receive your own data with useAppMessage.

Events reference

Every daily-js event and its payload.