Clients.get()

The get() method of the Clients interface gets a service worker client matching a given id and returns it in a Promise.

Syntax

self.clients.get(id).then(function(client) {
  // do something with your returned client
});

Parameters

id

A DOMString representing the id of the client you want to get.

Return value

A Promise that resolves to a Client object or undefined.

Examples

self.clients.get(id).then(function(client) {
  self.clients.openWindow(client.url);
});

Specifications

Specification
Service Workers 1
# clients-get

Browser compatibility

BCD tables only load in the browser