This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Note: This feature is available in Dedicated Web Workers.
The getPorts() method of the Serial interface returns a Promise that resolves with an array of SerialPort objects representing serial ports connected to the host which the origin has permission to access.
getPorts()
None.
A Promise that resolves with an array of SerialPort objects.
SecurityError DOMException
The returned Promise rejects with this error in either of the following situations:
serial Permissions Policy blocks the use of this feature.The following example uses getPorts() to initialize a list of available ports.
navigator.serial.getPorts().then((ports) => {
// Initialize the list of available ports with `ports` on page load.
});
| Specification |
|---|
| Web Serial API> # dom-serial-getports> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
getPorts |
89 | 89 | No | 75 | No | No | No | No | No | No | No | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Serial/getPorts