JavaScript Navigator usb Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

navigator.usb is a read-only property that returns a USB object for this document — the entry point to the WebUSB API for finding and connecting USB devices with user permission (MDN).

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

Syntax

Use navigator.usb. Start with this line.

JavaScript
navigator.usb
CallWhat it does
navigator.usbPrimary signature.

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

Library declarations
JavaScript
navigator.usb

Parameters

This member has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*USB (EventTarget)

JavaScript Examples

Example 1 — Feature Detection

Check whether WebUSB is exposed before calling any methods.

JavaScript
if ("usb" in navigator) {
  console.log("WebUSB available");
} else {
  console.log("WebUSB not supported");
}
Try It Yourself

How It Works

  1. Ask the browser. The in operator checks for the property.
  2. Gate your code. Only call requestDevice / getDevices when present.
  3. Expect gaps. Limited availability means many browsers omit the API.
  4. No side effects. Detection does not open a device picker.

Example 2 — List Paired Devices

Read devices the user already allowed that are currently attached.

JavaScript
async function listUsb() {
  if (!navigator.usb) {
    console.log("WebUSB not supported");
    return;
  }
  const devices = await navigator.usb.getDevices();
  console.log("paired devices:", devices.length);
  devices.forEach((d) => {
    console.log(d.productName || "(unnamed)", d.vendorId, d.productId);
  });
}

listUsb();
Try It Yourself

How It Works

  1. Detect first. Exit early when navigator.usb is missing.
  2. Await getDevices(). Resolves to an array of USBDevice objects.
  3. No picker. This only returns previously paired, attached devices.
  4. Inspect fields. Names and IDs help you label hardware in the UI.

Example 3 — Request a Device (User Gesture)

Open the pairing UI from a button click. Replace the filter with your vendor ID.

JavaScript
async function pairUsb() {
  if (!navigator.usb) {
    console.log("WebUSB not supported");
    return;
  }
  try {
    const device = await navigator.usb.requestDevice({
      filters: [{ vendorId: 0x2341 }] // example Arduino vendor
    });
    console.log("selected:", device.productName || "(unnamed)");
  } catch (err) {
    console.log("cancelled or failed:", err.name);
  }
}

// Call pairUsb() from a button click handler
Try It Yourself

How It Works

  1. User gesture. Call from a click/tap — not from page load.
  2. Pass filters. Narrow the picker by vendorId / productId (or class fields).
  3. Handle cancel. Closing the dialog rejects the Promise — catch it.
  4. Demo vendor. 0x2341 is an example Arduino ID; use your device’s IDs in real apps.

Browser Support

Navigator.usb is part of the WebUSB API. MDN marks the USB interface Experimental and Limited availability (not Baseline). Requires a secure context.

✓ Experimental · Limited availability

Navigator.usb

Best support in Chromium-based browsers (Chrome, Edge, Opera). Missing or unavailable in Safari and Firefox. Always feature-detect.

Limited Not Baseline
Google Chrome Supported (Chromium)
Yes
Microsoft Edge Supported (Chromium)
Yes
Opera Supported (Chromium)
Yes
Mozilla Firefox Not supported
No
Apple Safari Not supported
No
Internet Explorer Not supported
No
usb Chromium-first

Bottom line: Ship behind a feature detect. See the MDN usb reference. Prefer serial/hid when those APIs match your device.

Frequently Asked Questions

It is a read-only Navigator property that returns a USB object — the entry point for the WebUSB API so your page can find and connect to USB devices (with the user’s permission).
MDN marks the USB interface Experimental and Limited availability (not Baseline). It is not Deprecated or Non-standard. Always feature-detect, use HTTPS, and keep a non-WebUSB fallback.
Yes. It is available only in secure contexts (HTTPS or localhost) in supporting browsers.
navigator.usb.requestDevice(options) starts the browser’s pairing flow so the user can select a USB device. Call it from a user gesture. It resolves to a USBDevice.
navigator.usb.getDevices() returns previously paired attached devices as an array of USBDevice objects — without showing a new picker by itself.
WebUSB targets broader USB device access. Web Serial focuses on serial / virtual COM ports. WebHID focuses on HID-class devices. Choose the API that matches your hardware protocol.

Next: userActivation

Learn how navigator.userActivation reports sticky and transient user activation.

userActivation 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.

10 people found this page helpful