Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

WebRTC lets two browsers exchange live audio, video, and data directly when network conditions allow it. It does not, however, find the other browser or negotiate a call by itself. A working React video chat therefore has three cooperating parts: a React UI and media layer in each browser, an application-defined signaling channel for offers, answers, and ICE candidates, and ICE servers (STUN and, when necessary, TURN) that help the peers discover a usable network route.

This guide builds that flow for a two-person call. It shows where each API belongs, how to sequence offer/answer negotiation, how to integrate the connection with React effects and refs, and how to release cameras, microphones, peer connections, and signaling resources safely.

What WebRTC does—and what it does not do

MDN describes WebRTC as “a fully peer-to-peer technology for the real-time exchange of audio, video, and data, with one central caveat.” The caveat is signaling: the browsers still need a way to discover one another and negotiate what they will send.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

WebRTC supplies browser APIs such as getUserMedia(), RTCPeerConnection, session descriptions, ICE candidates, and media tracks. Your application must provide the signaling process that carries those negotiation messages between the intended peers. Signaling can use WebSocket, HTTP, or another transport; WebRTC does not mandate one. The signaling service normally routes JSON messages without interpreting the SDP inside them.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

The three pieces in a two-person call

  • Peer A and Peer B: each browser captures local media, creates an RTCPeerConnection, sends tracks, receives remote tracks, and observes connection state.
  • Signaling: an application service routes an offer, an answer, and ICE candidates. It is a coordination channel, not the media path in this architecture.
  • ICE servers: STUN helps a peer learn reachable network addresses; TURN provides a relay path when a direct route cannot be established. Use servers that you operate or are authorized to use, and treat any public example server as demonstration-only.

Direct media versus a relay

ICE tests possible routes. If the peers can reach one another directly, media may use a host or server-reflexive candidate. Restrictive firewalls, symmetric NAT, corporate networks, or other policies can prevent that. A TURN relay can make the call reachable by forwarding media, but it adds relay bandwidth, operational cost, and usually another network hop. A successful call is not proof that the path is direct; inspect ICE and candidate-pair information when that distinction matters.

How the offer and answer move through the system

The caller (the offerer) and callee (the answerer) each create a peer connection with the same general configuration. The exact signaling envelope is your application’s design; the sequence below is the important part.

  1. The caller obtains local media with navigator.mediaDevices.getUserMedia(), adds every track to its peer connection with addTrack(), and creates an offer.
  2. The caller applies that offer with setLocalDescription(), then sends the resulting session description through signaling.
  3. The callee receives the offer, applies it with setRemoteDescription(), obtains and adds its own local tracks, creates an answer, applies it with setLocalDescription(), and sends the answer.
  4. The caller receives the answer and applies it with setRemoteDescription().
  5. Both peers send ICE candidates as they are gathered. Each side passes received candidates to addIceCandidate() after the relevant remote description has been set.
  6. ICE can continue gathering and checking after media begins. Candidate exchange is not a one-time guarantee that the first route will remain usable.

The callee must apply the remote offer before creating its answer. Reversing that order produces an invalid negotiation state or an answer that does not describe the caller’s offer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build the React video surface first

Video elements are DOM objects, not ordinary render data. Keep references to them with useRef, then assign streams imperatively. Keep user-visible status—such as “connecting,” “connected,” or “failed”—in React state.

import { useEffect, useRef, useState } from "react";

export default function VideoCall({ roomId, signaling }) {
  const localVideoRef = useRef(null);
  const remoteVideoRef = useRef(null);
  const peerRef = useRef(null);
  const localStreamRef = useRef(null);
  const pendingCandidatesRef = useRef([]);
  const [status, setStatus] = useState("idle");

  return (
    <section>
      <p role="status">{status}</p>
      <div>
        <video ref={localVideoRef} autoPlay muted playsInline />
        <video ref={remoteVideoRef} autoPlay playsInline />
      </div>
    </section>
  );
}

autoPlay lets playback begin when the browser permits it, playsInline avoids forced full-screen behavior on browsers that support that mode, and muted on the local preview prevents feedback. The remote element should not be muted if the user is meant to hear the other participant.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Why refs are appropriate here

Changing a MediaStream or an RTCPeerConnection does not need to trigger a render. Refs provide stable, imperative storage for these long-lived browser objects. React state is still useful for status text, buttons, and error messages. An Effect should own setup and return cleanup; every reactive value used by that Effect belongs in its dependency list.

Capture local media and create the connection

getUserMedia() requires a secure context in supported browsers and prompts for camera and microphone permission. A denial, missing device, or browser policy failure rejects the promise, so the call must handle that path and clean up anything already created.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The following component assumes a signaling object with send(message) and subscribe(handler) methods. The transport could be a WebSocket or another application service; the shape is intentionally application-defined.

useEffect(() => {
  let disposed = false;
  let unsubscribe;

  const pc = new RTCPeerConnection({
    iceServers: [
      { urls: "stun:stun.example.net:3478" },
      { urls: "turn:turn.example.net:3478", username: "user", credential: "secret" }
    ]
  });
  peerRef.current = pc;
  setStatus("starting");

  const fail = (error) => {
    console.error(error);
    setStatus("failed");
  };

  pc.ontrack = (event) => {
    const [stream] = event.streams;
    if (remoteVideoRef.current && stream) {
      remoteVideoRef.current.srcObject = stream;
    }
  };

  pc.onicecandidate = (event) => {
    if (event.candidate) {
      signaling.send({
        type: "ice-candidate",
        roomId,
        candidate: event.candidate
      });
    }
  };

  pc.onconnectionstatechange = () => {
    setStatus(pc.connectionState);
  };

  unsubscribe = signaling.subscribe(async (message) => {
    try {
      if (disposed) return;

      if (message.type === "offer") {
        await pc.setRemoteDescription(message.description);
        const answer = await pc.createAnswer();
        await pc.setLocalDescription(answer);
        signaling.send({ type: "answer", roomId, description: pc.localDescription });
      } else if (message.type === "answer") {
        await pc.setRemoteDescription(message.description);
      } else if (message.type === "ice-candidate") {
        if (pc.remoteDescription) {
          await pc.addIceCandidate(message.candidate);
        } else {
          pendingCandidatesRef.current.push(message.candidate);
        }
      }
    } catch (error) {
      fail(error);
    }
  });

  (async () => {
    try {
      const stream = await navigator.mediaDevices.getUserMedia({
        audio: true,
        video: true
      });

      if (disposed || pc.signalingState === "closed") {
        stream.getTracks().forEach((track) => track.stop());
        return;
      }

      localStreamRef.current = stream;
      if (localVideoRef.current) {
        localVideoRef.current.srcObject = stream;
      }
      stream.getTracks().forEach((track) => pc.addTrack(track, stream));
      setStatus("media-ready");
    } catch (error) {
      fail(error);
      closeResources();
    }
  })();

  return () => {
    disposed = true;
    if (unsubscribe) unsubscribe();
    closeResources();
  };

  function closeResources() {
    const stream = localStreamRef.current;
    if (stream) {
      stream.getTracks().forEach((track) => track.stop());
      localStreamRef.current = null;
    }
    if (localVideoRef.current) localVideoRef.current.srcObject = null;
    if (remoteVideoRef.current) remoteVideoRef.current.srcObject = null;
    if (pc.signalingState !== "closed") pc.close();
    if (peerRef.current === pc) peerRef.current = null;
  }
}, [roomId, signaling]);

The example uses placeholder hostnames to show the configuration shape; replace them with ICE services you control or are authorized to use. A production deployment should not expose long-lived TURN credentials in a client bundle. Use a credentialing design appropriate to your service.

Use addTrack(), not the obsolete stream API

Add each audio and video track with pc.addTrack(track, stream). The older addStream() API is obsolete and should not be used for new code. Track-level events and controls also make it easier to mute, replace, or stop one source without treating the entire stream as an opaque object.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Complete the offerer and answerer roles

Only one side should initiate the offer for a simple two-person call. Your signaling protocol needs a deterministic rule—room creator, assigned caller, or a server-issued role—so both peers do not create competing offers.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Offerer function

async function createOffer(pc, signaling, roomId) {
  const offer = await pc.createOffer();
  await pc.setLocalDescription(offer);
  signaling.send({
    type: "offer",
    roomId,
    description: pc.localDescription
  });
}

Call this only after local tracks have been added, unless you deliberately implement renegotiation for later track changes. The onicecandidate handler can send candidates incrementally while the description is being exchanged.

Answerer function

async function acceptOffer(pc, offer, signaling, roomId) {
  await pc.setRemoteDescription(offer);
  const answer = await pc.createAnswer();
  await pc.setLocalDescription(answer);
  signaling.send({
    type: "answer",
    roomId,
    description: pc.localDescription
  });
}

When an answer arrives at the offerer, call setRemoteDescription(answer). Keep signaling messages scoped to a room or call identifier so a candidate from one call cannot be applied to another connection.

Queue ICE candidates safely

Candidate messages can arrive before the remote description. Calling addIceCandidate() too early can reject because the peer connection does not yet know which session the candidate belongs to. Queue candidates until remoteDescription is present, then flush them.

async function flushCandidates(pc, queue) {
  if (!pc.remoteDescription) return;
  while (queue.length) {
    const candidate = queue.shift();
    await pc.addIceCandidate(candidate);
  }
}

// Immediately after setRemoteDescription(message.description):
await flushCandidates(pc, pendingCandidatesRef.current);

Some signaling systems send an explicit end-of-candidates marker; preserve that marker if your protocol uses one. Continue handling candidates after the first media packets arrive because ICE may discover a better or more reachable route.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

React lifecycle, Strict Mode, and teardown races

React Effects synchronize a component with external systems. In development Strict Mode, React may run an extra setup-and-cleanup cycle to expose incomplete cleanup. A call that works only when setup runs once is not lifecycle-safe.

Make cleanup symmetric with setup:

  • unsubscribe the signaling listener and close the signaling socket if this component owns it;
  • stop every local audio and video track so the camera and microphone are released;
  • clear srcObject on video elements when the component owns those assignments;
  • close the RTCPeerConnection if it is not already closed;
  • clear refs or pending candidate queues that must not survive the call.

Media acquisition is asynchronous. The component can unmount after requesting permission but before the promise resolves. Use a disposed flag or an equivalent abort strategy; if a stream arrives after teardown, stop its tracks immediately and do not attach it to a closed connection. This prevents a camera indicator from remaining on after the UI has disappeared and avoids events targeting stale objects.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Handle permissions, devices, and connection states

Permission and capture failures

Distinguish common getUserMedia() failures in your UI:

  • Permission denied: explain that the user must allow camera and microphone access in the browser or site settings, then retry.
  • No usable device: offer a device check, ask the user to connect or select a camera/microphone, and retry.
  • Constraint failure: request less specific constraints. Starting with { audio: true, video: true } is more portable than assuming a particular resolution or camera name.
  • Insecure or restricted context: serve the page from a context where the browser permits media capture and explain any embedded-frame policy that blocks it.

A USB webcam is optional. The code only requires a camera and microphone that the browser can expose; it does not require a particular external model.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Connection-state handling

Use connectionState and, when diagnosing ICE specifically, iceConnectionState to drive status text and recovery. Typical user-facing states include:

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
  • new/checking: candidates are being gathered or tested;
  • connected/completed: a usable route is active;
  • disconnected: connectivity may recover; avoid immediately destroying the call;
  • failed: restart ICE or ask the user to retry after checking network and server configuration;
  • closed: the call has ended and resources should be released.

Do not treat “connected” as proof of a direct peer-to-peer path. A TURN relay may be carrying the media.

Troubleshoot the failures that matter most

No offer or answer appears

  • Verify both peers joined the same room or call identifier.
  • Log signaling message types and sender/recipient routing, without assuming the signaling service understands SDP.
  • Confirm only the designated offerer calls createOffer().
  • Check that the answerer calls setRemoteDescription(offer) before createAnswer().

addIceCandidate() rejects

Check whether the remote description has been set. Queue early candidates and flush the queue immediately afterward. Also verify that the candidate belongs to the same peer connection and call identifier.

The call stays in checking or fails on some networks

Inspect whether a TURN server is configured and reachable. A STUN-only configuration cannot relay traffic when direct candidates are blocked. Confirm that the TURN service is authorized, credentials are valid, and required ports and transports are allowed by the network. Do not promise that an arbitrary public server will work in production.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Remote video never appears

  • Confirm the sender added tracks before creating the offer or renegotiated after adding them.
  • Confirm ontrack is registered before the remote track arrives.
  • Assign the event’s stream to remoteVideoRef.current.srcObject and check browser autoplay policies.
  • Inspect whether the remote track is muted or ended and whether the peer connection has failed.

Camera remains active after leaving

Stop every track in the owned local stream, detach the local video element, unsubscribe signaling, and close the peer connection. Test the sequence by mounting, unmounting, and remounting the component in development Strict Mode.

Signaling transport and connectivity choices

Choice What it provides Trade-offs
WebSocket signaling A persistent, bidirectional channel suited to real-time offer, answer, and candidate messages. Requires connection lifecycle, authentication, room routing, and reconnect handling in your application.
HTTP or another application transport Can fit an existing request/response or messaging architecture. You must design polling, callbacks, queues, or another mechanism for timely bidirectional delivery.
Direct ICE candidate route Peers exchange media without a relay when network policy permits. Reachability is not guaranteed across restrictive NATs and firewalls; route quality can change.
TURN relay Provides a fallback path when direct connectivity cannot be established. Relay bandwidth and operations cost money, and an additional hop can affect latency; capacity and authorization must be managed.

These are architectural choices, not interchangeable WebRTC settings. Keep signaling and ICE configuration separate so you can change the message transport without rewriting media handling.

A production-readiness checklist

  • Serve the React application in a context that permits camera and microphone capture.
  • Authenticate signaling participants and authorize room membership.
  • Use a deterministic offerer/callee role for the initial negotiation.
  • Route offers, answers, and candidates only to the intended call.
  • Configure STUN and an authorized TURN service appropriate to your deployment.
  • Queue candidates until the remote description exists.
  • Handle permission denial, missing devices, failed ICE, disconnects, and retries in the UI.
  • Stop media tracks and close peer and signaling resources on every exit path, including partial startup.
  • Test Strict Mode, rapid navigation, denied permissions, unplugged devices, and restrictive networks.
  • Record connection and ICE states for diagnostics, while avoiding sensitive media or credential logging.

With those pieces in place, React is responsible for presenting controls and status while the browser’s WebRTC objects handle media negotiation and transport. The signaling service coordinates the peers; ICE determines how they can reach each other; and disciplined Effect cleanup keeps the call from outliving the component that owns it.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.