WorkerNavigator: serviceWorker property

Limited availability

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.

Note: This feature is only available in Web Workers.

The serviceWorker read-only property of the WorkerNavigator interface returns the ServiceWorkerContainer object for the associated document, which provides access to registration, removal, upgrade, and communication with the ServiceWorker.

The feature may not be available in private mode.

Value

ServiceWorkerContainer.

Examples

This code checks if the browser supports using service worker in workers.

js
if ("serviceWorker" in navigator) {
  // Supported!
}

Specifications

Specification
Service Workers Nightly
# navigator-serviceworker

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
serviceWorker
Chrome – No support
Chrome
footnote
footnote See bug 40364838
Edge – No support
Edge
footnote
footnote See bug 40364838
Firefox – Full support
Firefox 133 (Release date: 2024-11-26)
footnote Full support
Opera – No support
Opera
footnote
footnote See bug 40364838
Safari – Full support
Safari 11.1 (Release date: 2018-04-12)
footnote Full support
Chrome Android – No support
Chrome Android
footnote
footnote See bug 40364838
Firefox for Android – Full support
Firefox for Android 133 (Release date: 2024-11-26)
footnote Full support
Opera Android – No support
Opera Android
footnote
footnote See bug 40364838
Safari on iOS – Full support
Safari on iOS 11.3 (Release date: 2018-03-29)
footnote Full support
Samsung Internet – No support
Samsung Internet
footnote
footnote See bug 40364838
WebView Android – No support
WebView Android
footnote
footnote See bug 40364838
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

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

Full support
Full support
No support
No support
See implementation notes.

See also