Monitoring Network Quality - React
VideoSDK gives you two ways to keep an eye on network conditions during a meeting:
- Participant network quality: the server measures every participant's connection and reports a quality level for what they send (uplink) and what they receive (downlink). Use it to show network indicators next to participants.
- Quality limitation: the
onQualityLimitationevent tells you when the local participant's media quality is reduced, or restored, because of CPU, bandwidth or congestion.
Participant Network Quality
onNetworkQualityChanged
-
This callback is triggered with a participant's network quality, measured by the server, for both directions:
uplink: the connection from the participant to the server (the media they send).downlink: the connection from the server to the participant (the media they receive).
-
It can be subscribed to using the
useParticipanthook, and works for the local participant as well as remote participants. -
Passing the callback subscribes to that participant's network quality while the component is mounted. It unsubscribes when the component unmounts or the callback is removed, so only participants that are actually displayed are subscribed.
-
The first call carries the current quality, once the server knows it. After that, it is triggered whenever the
levelor thereasonsof either direction change, including when the connection recovers. -
The subscription is restored automatically after a reconnect.
Network quality data
The callback receives { uplink, downlink }. uplink and downlink have the same shape:
| Property | Type | Description |
|---|---|---|
level | string | good, fair, poor, bad, or unknown. It is unknown when no media flows in that direction. |
score | number | From 1 (bad) to 5 (good). It is 0 when the level is unknown. |
reasons | array | Every signal pulling the level down, worst first. It is empty when the level is good or unknown. |
metrics | object | The raw values behind the level. A field is present only when it was measured. |
Possible values of reasons:
| Reason | Meaning |
|---|---|
packetLoss | High packet loss |
rtt | High round-trip time |
jitter | High jitter |
bandwidth | Not enough bandwidth |
stalled | Media has stalled |
Fields of metrics:
| Metric | Direction | Description |
|---|---|---|
packetLoss | Both | Packet loss, in %. |
jitter | Both | Audio jitter, in ms. |
rtt | Downlink | Round-trip time, in ms. |
availableBitrate | Downlink | The server's bandwidth estimate for the participant, in bps. |
limitedStreams | Downlink | Number of video streams forwarded below the quality the participant asked for. |
videoStreams | Downlink | Number of video streams the participant receives. |
activeLayers | Uplink | Number of simulcast layers the participant is sending now. |
peakLayers | Uplink | The most simulcast layers the participant has sent so far. |
Example
This example shows a network indicator for each participant.
import { useState } from "react";
import { useParticipant } from "@videosdk.live/react-sdk";
function ParticipantView({ participantId }) {
const [networkQuality, setNetworkQuality] = useState(null);
function onNetworkQualityChanged({ uplink, downlink }) {
setNetworkQuality({ uplink, downlink });
}
const { displayName } = useParticipant(participantId, {
onNetworkQualityChanged,
});
return (
<div>
<p>{displayName}</p>
{networkQuality && (
<p>
Uplink: {networkQuality.uplink.level}
{networkQuality.uplink.reasons.length > 0 &&
` (${networkQuality.uplink.reasons.join(", ")})`}
{" | "}
Downlink: {networkQuality.downlink.level}
{networkQuality.downlink.reasons.length > 0 &&
` (${networkQuality.downlink.reasons.join(", ")})`}
</p>
)}
</div>
);
}
Getting the current network quality
useParticipant also returns getNetworkQuality(), which returns the participant's last known { uplink, downlink }. The value is kept up to date while onNetworkQualityChanged is passed.
const { getNetworkQuality } = useParticipant(participantId, {
onNetworkQualityChanged,
});
const { uplink, downlink } = getNetworkQuality();
console.log(uplink.level, downlink.level);
Quality Limitation
VideoSDK's onQualityLimitation event helps you stay informed whenever media quality is impacted or restored during a meeting. This allows you to take proactive steps and ensure a smooth user experience.
onQualityLimitation
-
This event is triggered whenever a media quality limitation is either detected or resolved during a meeting.
-
The callback includes a
typeparameter that specifies the cause of the quality limitation. Possible values:cpu: Quality is reduced due to high CPU usage.bandwidth: Quality is reduced due to insufficient bandwidth.congestion: Quality is reduced due to network congestion.
-
The callback also includes a
stateparameter that indicates the current status of the limitation:detected: A limitation has been identified.resolved: The limitation has been cleared.
-
A
timestampparameter is provided, representing the exact time (in milliseconds since epoch) when the event occurred. -
It can be subscribed to using the
useMeetinghook.
Example
Here is an example demonstrating the usage of the event mentioned on this page.
import { useMeeting } from "@videosdk.live/react-sdk";
function onQualityLimitation(data) {
const { type, state, timestamp } = data;
}
const {
meetingId
...
} = useMeeting({
onQualityLimitation,
...
});
API Reference
The API references for all the methods and events utilized in this guide are provided below.
Got a Question? Ask us on discord

