Skip to main content
useRoomExp(params?): Object The ejection date is derived from room or token configuration: eject_after_elapsed, eject_at_room_exp, and exp. The optional onCountdown callback fires every second with the remaining hours, minutes, and seconds.

Parameters (optional)

onCountdown
Function
When onCountdown is set and the room is configured to eject the local participant at a given time, onCountdown will be called every second with an object parameter with keys hours, minutes and seconds.

Return value

An object with the following properties:
ejectDate
Date | null
The date when the local participant will be automatically ejected from the meeting.
{
  "ejectDate": "Wed Jul 26 2023 09:48:42 GMT+0200 (Central European Summer Time)"
}

Example

import { useRoomExp } from '@daily-co/daily-react';
import { useCallback, useState } from 'react';

export const UseRoomExpDemo = () => {
  const [countdown, setCountdown] = useState('');
  const { ejectDate } = useRoomExp({
    onCountdown: useCallback(({ hours, minutes, seconds }) => {
      if (hours > 0) return;
      setCountdown(`${minutes}:${seconds.toString().padStart(2, '0')}`);
    }, []),
  });

  return (
    <div>
      Meeting ends in {countdown} (at {ejectDate.toISOString()})
    </div>
  );
};

See also