Clients.matchAll()

The matchAll() method of the Clients interface returns a Promise for a list of service worker Client objects. Include the options parameter to return all service worker clients whose origin is the same as the associated service worker's origin. If options are not included, the method returns only the service worker clients controlled by the service worker.

Syntax

self.clients.matchAll(options).then(function(clients) {
  // do something with your clients list
});

Parameters

options Optional

An options object allowing you to set options for the matching operation. Available options are:

  • includeUncontrolled: A boolean value — if set to true, the matching operation will return all service worker clients who share the same origin as the current service worker. Otherwise, it returns only the service worker clients controlled by the current service worker. The default is false.
  • type: Sets the type of clients you want matched. Available values are "window", "worker", "sharedworker", and "all". The default is "window".

Return value

A Promise that resolves to an array of Client objects. In Chrome 46/Firefox 54 and later, this method returns clients in most recently focused order, correct as per spec.

Examples

clients.matchAll(options).then(function(clientList) {
  for (var i = 0 ; i < clientList.length ; i++) {
    if (clientList[i].url === 'index.html') {
      clients.openWindow(clientList[i]);
      // or do something else involving the matching client
    }
  }
});

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
matchAll
47
Client objects returned in most recent focus order.
17
Client objects returned in most recent focus order.
44
Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API.
54
Client objects returned in most recent focus order.
No
32
11.1
47
Client objects returned in most recent focus order.
47
Client objects returned in most recent focus order.
44
54
Client objects returned in most recent focus order.
32
11.3
4.0
Client objects returned in most recent focus order.
options_includeUncontrolled_parameter
47
Client objects returned in most recent focus order.
≤79
Client objects returned in most recent focus order.
45
includeUncontrolled support.
No
38
11.1
47
Client objects returned in most recent focus order.
47
Client objects returned in most recent focus order.
45
includeUncontrolled support.
41
11.3
5.0
Client objects returned in most recent focus order.

© 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/matchAll