Definition
clients.claim()
self.clients.claim() is called inside the activate event of a service worker to make it start controlling every open page on the origin right away, rather than the default behaviour where a page keeps being controlled by whatever worker was active when it first loaded until the next navigation.
Typical usage: self.addEventListener("activate", (event) => { event.waitUntil(clients.claim()); });, almost always paired with skipWaiting() in the install handler so the whole update reaches every open tab as fast as possible.
Without clients.claim(), a page loaded before the new worker activated keeps talking to the old worker instance for its fetch and message events until it is reloaded or navigated, even though a newer worker is technically active for the origin.
clients.claim() returns a promise that resolves once all matching clients are claimed, which is why it should be wrapped in event.waitUntil() so the activate event does not resolve prematurely.
The very first time a service worker registers on a page, that page is never controlled by it (nor by clients.claim()) — control only ever starts on the next navigation or via claim() for pages loaded under a previous worker version.