FetchEvent: replacesClientId property

Note: This feature is only available in Service Workers.

The replacesClientId read-only property of the FetchEvent interface is the id of the client that is being replaced during a page navigation.

For example, when navigating from page A to page B replacesClientId is the ID of the client associated with page A. It can be an empty string when navigating from about:blank to another page, as about:blank's client will be reused, rather than be replaced.

Additionally, if the fetch isn't a navigation, replacesClientId will be an empty string. This could be used to access/communicate with a client that will imminently be replaced, right before a navigation.

Value

A string.

Examples

js
self.addEventListener("fetch", (event) => {
  console.log(event.replacesClientId);
});

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android
replacesClientId No No No No 11.1–16 No No No 11.3–16 No No

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/replacesClientId