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

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
get
51
17
45
Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API.
No
38
11.1
No
51
45
41
11.3
5.0

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