SharedWorker: port property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The port property of the SharedWorker interface returns a MessagePort object used to communicate and control the shared worker.

Value

A MessagePort object.

Examples

The following code snippet shows creation of a SharedWorker object using the SharedWorker() constructor. Multiple scripts can then access the worker through a MessagePort object accessed using the SharedWorker.port property — the port is started using its start() method:

js
const myWorker = new SharedWorker("worker.js");
myWorker.port.start();

For a full example, see our Basic shared worker example (run shared worker.)

Specifications

Specification
HTML
# dom-sharedworker-port-dev

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
port
Chrome – Full support
Chrome 5 (Release date: 2010-05-25)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 29 (Release date: 2014-04-29)
footnote Full support
Opera – Full support
Opera 10.6 (Release date: 2010-07-01)
footnote Full support
Safari – No support
Safari 5 – 6 (Release date: 2010-06-07)
footnote Removed in 7 and later
Safari – Full support
Safari 16 (Release date: 2022-09-12)
footnote Full support
Chrome Android – Preview support
Chrome Android 148 (Release date: 2026-05-05)
footnote Preview browser support
Firefox for Android – Full support
Firefox for Android 33 (Release date: 2014-10-14)
footnote Full support
Opera Android – No support
Opera Android 11 – 12.1 (Release date: 2011-03-22)
footnote Removed in 14 and later
Safari on iOS – No support
Safari on iOS 5 – 6 (Release date: 2011-10-12)
footnote Removed in 7 and later
Safari on iOS – Full support
Safari on iOS 16 (Release date: 2022-09-12)
footnote Full support
Samsung Internet – No support
Samsung Internet 4 – 4.2 (Release date: 2016-03-11)
footnote Removed in 5 and later
WebView Android – Preview support
WebView Android 148 (Release date: 2026-05-05)
footnote Preview browser support
WebView on iOS – No support
WebView on iOS 5 – 6 (Release date: 2011-10-12)
footnote Removed in 7 and later
WebView on iOS – Full support
WebView on iOS 16 (Release date: 2022-09-12)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
In development. Supported in a pre-release version.
In development. Supported in a pre-release version.
Has more compatibility info.

See also