Skip to main content
useNetwork(params?): Object useNetwork can also be used to set up optional callbacks for daily-js network events.

Parameters (optional)

onNetworkQualityChange
Function
Event callback for the network-quality-change event
onNetworkConnection
Function
Event callback for the network-connection event

Return value

An object with the following properties:
getStats
Function
Details the latest network stats, equivalent to calling getNetworkStats()
networkState
string
'good' | 'warning' | 'bad' | 'unknown', check getNetworkStats() for details
networkStateReasons
Array<string>
Possible reasons are 'sendPacketLoss' | 'recvPacketLoss' | 'roundTripTime' | 'availableOutgoingBitrate', check getNetworkStats() for details
networkStatus
string
'connected' | 'interrupted', the current network connection status
quality
number
Deprecated 0.23.0 A subjective calculation of the current network quality on a scale of 1-100, defaults to 100
threshold
string
Deprecated 0.23.0 'good' | 'low' | 'very-low', an assessment of the current network quality. The threshold value is calculated from network stats averaged over an approximately 30-second rolling window. By default, we lower the bandwidth used for the call when the network quality drops to 'low'; defaults to 'good'
topology
string
'none' | 'peer' | 'sfu', the network connection type of the current call, defaults to 'none'
{
  "getStats": <Function>,
  "networkState": "good",
  "networkStateReasons": [],
  "networkStatus": "connected",
  "quality": 100,
  "threshold": "good",
  "topology": "sfu",
}

Example

import { useNetwork } from '@daily-co/daily-react';

export const UseNetworkDemo = () => {
  const network = useNetwork();

  return <div>Network state: {network.networkState}</div>;
};

See also