Back to Content

FetchEvent: clientId property

files/en-us/web/api/fetchevent/clientid/index.md

latest878 B
Original Source

{{APIRef("Service Workers API")}}{{AvailableInWorkers("service")}}

The clientId read-only property of the {{domxref("FetchEvent")}} interface returns the id of the {{domxref("Client")}} that the current service worker is controlling.

The {{domxref("Clients.get()")}} method could then be passed this ID to retrieve the associated client.

Value

A string that represents the client ID.

Examples

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

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also