navigator.usb is the entry point for the WebUSB API. Learn the USB object, requestDevice / getDevices, connect events, secure context rules, five examples, and try-it labs.
01
Kind
Read-only property
02
Returns
USB object
03
Status
Experimental
04
Context
Secure (HTTPS)
05
Pick device
requestDevice()
06
Reuse
getDevices()
Fundamentals
Introduction
USB devices range from custom gadgets and Arduino-style boards to specialty hardware that does not fit neatly into serial or HID protocols. WebUSB lets a web page talk to those devices — with the user’s permission.
navigator.usb is read-only. When WebUSB is available, it returns a USB object you use to request access, list previously paired devices, and listen for connect / disconnect events.
💡
Permission first
You cannot silently open every USB device on the user’s desk. requestDevice() starts a pairing flow and needs a user gesture (button click). Always explain why you need the device.
Concept
Understanding the usb Property
Think of navigator.usb as the WebUSB “front desk.” The real work happens on the USB object it returns.
USB object — entry point with methods and events.
requestDevice() — user picks a device and grants access (returns a USBDevice).
getDevices() — list previously paired attached devices.
connect / disconnect — events when paired devices appear or leave.
Filters — limit the picker by vendorId, productId, and related fields.
Experimental — feature-detect; do not require it for core UX.
Foundation
📝 Syntax
General form of the property:
JavaScript
navigator.usb
Value
A USB object when WebUSB is available in this context.
Missing / unavailable when unsupported, insecure, or blocked.
Common patterns
JavaScript
// Feature-detect:
if ("usb" in navigator && navigator.usb) {
// WebUSB entry point is available
}
// Request a device (must run from a click handler):
async function pickDevice() {
const filters = [
{ vendorId: 0x1209, productId: 0xa800 },
{ vendorId: 0x1209, productId: 0xa850 }
];
const device = await navigator.usb.requestDevice({ filters });
console.log(device.productName);
}
// List previously paired devices:
const known = await navigator.usb.getDevices();
Cheat Sheet
⚡ Quick Reference
Goal
Code
Get WebUSB entry
navigator.usb
Detect API
"usb" in navigator && navigator.usb
Pick a device
await navigator.usb.requestDevice({ filters })
List paired devices
await navigator.usb.getDevices()
Listen for plug-in
navigator.usb.addEventListener("connect", …)
Secure page?
window.isSecureContext
Status (MDN)
Experimental / not Baseline
Snapshot
🔍 At a Glance
Four facts to remember about navigator.usb.
Returns
USB
WebUSB entry
Status
experimental
Not Baseline
HTTPS
required
Secure context
Permission
user gesture
requestDevice
Compare
📋 WebUSB vs Web Serial vs WebHID
WebUSB (navigator.usb)
Web Serial
WebHID
Focus
Broader USB device access
Serial / virtual COM
HID-class devices
Pick method
requestDevice()
requestPort()
requestDevice()
Returns
USBDevice
SerialPort
HIDDevice[]
Best for
Custom USB protocols
Boards / printers over serial
Gamepads / HID gadgets
Status
Experimental / limited
Limited — check MDN
Limited / check MDN
Hands-On
Examples Gallery
Examples follow MDN WebUSB / navigator.usb patterns. Prefer Try It Yourself on HTTPS in a Chromium browser with a real USB device. requestDevice needs a button click.
📚 Getting Started
Detect WebUSB and confirm a secure context.
Example 1 — Feature Detection
Check whether the WebUSB entry point exists on navigator.
WebUSB missing
(or "WebUSB available" in a supporting browser)
How It Works
If missing, show a message and keep a non-WebUSB path (native tool, firmware updater, etc.).
Example 2 — Secure Context Check
WebUSB requires HTTPS / localhost — check both flags together.
JavaScript
console.log("secure: " + window.isSecureContext);
console.log("usb: " + Boolean(navigator.usb));
if (!window.isSecureContext) {
console.log("Serve over HTTPS to use WebUSB");
} else if (!navigator.usb) {
console.log("Secure, but WebUSB not exposed");
} else {
console.log("Ready to call getDevices / requestDevice");
}
navigator.usb belongs to the experimental WebUSB API and is not Baseline. Support is limited (commonly Chromium-based). Always feature-detect, use HTTPS, and keep a non-WebUSB fallback.
✓ Experimental · Not Baseline
Navigator.usb
WebUSB entry point for pairing USB devices from the browser. Great for demos when supported — never assume universal availability.
LimitedExperimental
Google ChromeWebUSB / Chromium path (check version)
Limited
Microsoft EdgeFollow Chromium WebUSB support
Limited
OperaFollow Chromium WebUSB support
Limited
Mozilla FirefoxTypically unavailable — feature-detect
Unavailable
Apple SafariTypically unavailable — feature-detect
Unavailable
Internet ExplorerNo WebUSB API support
Unavailable
usbLimited
Bottom line: Detect navigator.usb, call requestDevice from a user gesture, reuse getDevices on reload, and hide USB UI when the API is missing.
Wrap Up
Conclusion
navigator.usb is the experimental WebUSB entry point. Feature-detect it, use HTTPS, call requestDevice() from a button click, reuse getDevices() for known devices, and keep a fallback when the API is missing.
Filter by vendor / product IDs when you know your hardware
Handle cancel / permission errors gracefully
❌ Don’t
Assume every browser supports WebUSB
Open the picker on page load without a click
Require USB for core site features
Ignore Experimental / limited support warnings
Assign to navigator.usb
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about usb
Experimental WebUSB entry — pair with permission, reuse getDevices, stay on HTTPS.
5
Core concepts
📄01
Returns
USB
Value
🔌02
Pick
requestDevice
API
🔁03
Reuse
getDevices
Pattern
🔒04
HTTPS
required
Security
🎯05
Status
experimental
Detect
❓ 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 not Baseline (limited availability). 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.
Did you know?
The number of filters you pass to requestDevice() does not equal the number of devices shown. MDN: the browser lists matching devices it finds — one filter can match several attached gadgets.