The clientId
read-only property of the FetchEvent
interface returns the id of the Client
that the current service worker is controlling.
The Clients.get()
method could then be passed this ID to retrieve the associated client.
Syntax
var myClientId = fetchEvent.clientId;
Value
A DOMString
that represents the client ID.
Example
self.addEventListener('fetch', function(event) { console.log(event.clientId); });
Specifications
Specification | Status | Comment |
---|---|---|
Service Workers The definition of 'clientId' in that specification. |
Working Draft | Initial definition. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
clientId | Chrome Full support 49 | Edge Full support ≤79 | Firefox
Full support
45
| IE No support No | Opera Full support 36 | Safari No support No | WebView Android Full support 49 | Chrome Android Full support 49 | Firefox Android Full support 45 | Opera Android Full support 36 | Safari iOS No support No | Samsung Internet Android Full support 5.0 |
Legend
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.
- Experimental. Expect behavior to change in the future.
- See implementation notes.
- See implementation notes.