JavaScript Navigator connection Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

navigator.connection is a read-only property that returns a NetworkInformation object about the system’s network connection (MDN) — useful as a hint for adaptive loading (HD vs light content).

Read the notes below before you rely on this property. Prefer feature detection when support is limited.

Syntax

Use navigator.connection. Start with this line.

JavaScript
navigator.connection
CallWhat it does
navigator.connectionPrimary signature.

Built into the browser. Read navigator.connection on Navigator — no import required.

Library declarations
JavaScript
navigator.connection

Parameters

ParameterDescription
change eventOptional. React when connection changes

Return Value

Return ValueDescription
*NetworkInformation (read-only property)

JavaScript Examples

Example 1 — Feature Detect

Check whether the Network Information API is available.

JavaScript
if ("connection" in navigator && navigator.connection) {
  console.log("connection supported");
} else {
  console.log("connection missing — use defaults");
}
Try It Yourself

How It Works

  1. Use in. Safe check before reading fields.
  2. Confirm the object. Some environments expose the key as empty.
  3. Fallback. If missing, keep a sensible default quality.
  4. No side effects. Detection alone does not change the network.

Example 2 — Read Common Fields

Log effectiveType, downlink, rtt, and saveData.

JavaScript
const conn = navigator.connection;
if (!conn) {
  console.log("connection missing");
} else {
  console.log("effectiveType:", conn.effectiveType);
  console.log("downlink:", conn.downlink);
  console.log("rtt:", conn.rtt);
  console.log("saveData:", conn.saveData);
}
Try It Yourself

How It Works

  1. Grab the object. Store navigator.connection once.
  2. Read hints. Values are estimates, not exact measurements.
  3. Note units. downlink ≈ Mbps; rtt ≈ ms.
  4. Expect change. Numbers can update as the network shifts.

Example 3 — Adaptive Loading Hint

Choose light vs full quality from saveData and effectiveType.

JavaScript
function mediaQuality() {
  const conn = navigator.connection;
  if (!conn) return "default";

  const slow = ["slow-2g", "2g"].includes(conn.effectiveType);
  if (conn.saveData || slow) return "light";
  return "full";
}

console.log("quality:", mediaQuality());

// Optional: react when the connection changes
if (navigator.connection) {
  navigator.connection.addEventListener("change", () => {
    console.log("updated quality:", mediaQuality());
  });
}
Try It Yourself

How It Works

  1. Default first. Missing API → "default" quality.
  2. Honor saveData. Prefer light assets when the user wants less data.
  3. Check slow types. slow-2g / 2g → light path.
  4. Listen for change. Recompute when the network updates.

Browser Support

navigator.connection has limited availability on MDN — not Baseline. Chromium-based browsers are the usual targets; many others omit it.

✓ Limited · Not Baseline

Navigator.connection

Returns NetworkInformation (effectiveType, downlink, rtt, saveData, change). Feature-detect; use as adaptive-loading enhancement only.

Limited Not Baseline
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
connection Check MDN

Bottom line: Safe as progressive enhancement for media quality. Always provide defaults when the API is missing.

Frequently Asked Questions

It is a read-only Navigator property that returns a NetworkInformation object with details about the device's network connection — for example effectiveType, downlink, rtt, and saveData.
No. MDN marks it as limited availability (not Baseline). Support is strongest in Chromium-based browsers; Safari and Firefox often omit it. Always feature-detect.
A coarse connection quality label such as "slow-2g", "2g", "3g", or "4g". Use it as a hint for adaptive loading (for example lighter images on slow connections).
downlink is an estimate of bandwidth in megabits per second. rtt is an estimate of round-trip time in milliseconds. Values are approximate and can change.
A boolean that is true when the user (or browser) has requested reduced data usage. Prefer lighter assets when saveData is true.
No. The property is read-only. You read fields on the NetworkInformation object and can listen for its change event.

Next: contacts

Learn the related Navigator contacts property.

contacts tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

7 people found this page helpful