Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Web Workers.
The ServiceWorkerContainer
interface of the Service Worker API provides an object representing the service worker as an overall unit in the network ecosystem, including facilities to register, unregister and update service workers, and access the state of service workers and their registrations.
Most importantly, it exposes the ServiceWorkerContainer.register()
method used to register service workers, and the ServiceWorkerContainer.controller
property used to determine whether or not the current page is actively controlled.
Service workers can currently only be registered in the Window scope in some or all browsers, because the ServiceWorkerContainer
object is not exposed to DedicatedWorkerGlobalScope
and SharedWorkerGlobalScope
. Check the browser compatibility for information.