> ## Documentation Index
> Fetch the complete documentation index at: https://docs.daily.co/llms.txt
> Use this file to discover all available pages before exploring further.

# useDailyEvent

> Registers daily-js event listeners.

`useDailyEvent(params): void`

Listeners are automatically torn down when the calling component or hook unmounts.

## Parameters

<ParamField body="event" type="string" required>
  The `daily-js` [event](/reference/daily-js/events) to register.
</ParamField>

<ParamField body="callback" type="Function" required>
  A memoized callback reference to run when the event is emitted.
</ParamField>

<Warning>
  The `callback` param has to be a memoized reference (e.g. via [`useCallback`](https://reactjs.org/docs/hooks-reference.html#usecallback)). Otherwise a console error might be thrown indicating a potential re-render loop.
</Warning>

## Example

```jsx theme={null}
import { useDailyEvent } from '@daily-co/daily-react';
import { useCallback, useState } from 'react';

export const DailyEventDemo = () => {
  const [meetingState, setMeetingState] = useState('disconnected');

  useDailyEvent(
    'joined-meeting',
    useCallback((ev) => {
      setMeetingState('connected');
    }, [])
  );

  return <div>Meeting state: {meetingState}</div>;
};
```

## See also

<CardGroup>
  <Card title="Hooks" icon="code" iconType="solid">
    * [useThrottledDailyEvent()](/reference/daily-react/use-throttled-daily-event)
  </Card>

  <Card title="Events" icon="bolt" iconType="solid">
    * [Events reference](/reference/daily-js/events)
  </Card>
</CardGroup>
