clients.claim()
A service worker method that makes a newly activated worker take control of pages that are already open.
In more detail
It is usually called inside the activate event handler. Without it, a worker only controls pages loaded after it activated, so the first visit is not intercepted.
Related terms
- skipWaiting() — A service worker method that makes a newly installed version activate immediately instead of waiting for old tabs to close.
- service worker lifecycle — The states a service worker passes through: installing, installed and waiting, activating, activated, and finally redundant when replaced or failed.
Taught in
- Service Worker Lifecycle: Installation, Activation And Update — Frontend Architecture & Web Platform