Clients: matchAll() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.

Note: This feature is only available in Service Workers.

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

js
matchAll()
matchAll(options)

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

js
clients.matchAll(options).then((clientList) => {
  for (const client of clientList) {
    if (client.url === "index.html") {
      clients.openWindow(client);
      // or do something else involving the matching client
    }
  }
});

Specifications

Specification
Service Workers Nightly
# clients-matchall

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
matchAll
Chrome – Full support
Chrome 42 (Release date: 2015-04-14)
footnote
footnote Client objects returned in most recent focus order.
Edge – Full support
Edge 17 (Release date: 2018-04-30)
footnote
footnote Client objects returned in most recent focus order.
Firefox – Partial support
Firefox 44 – 53 (Release date: 2016-01-26)
footnote Partial support
footnote Before Firefox 54, Client objects were not returned in the most recent focus order as required by the specification.
Firefox – Full support
Firefox 54 (Release date: 2017-06-13)
footnote Full support
Opera – Full support
Opera 29 (Release date: 2015-04-28)
footnote Full support
Safari – Full support
Safari 11.1 (Release date: 2018-04-12)
footnote Full support
Chrome Android – Full support
Chrome Android 42 (Release date: 2015-04-15)
footnote
footnote Client objects returned in most recent focus order.
Firefox for Android – Partial support
Firefox for Android 44 – 53 (Release date: 2016-01-26)
footnote Partial support
footnote Before Firefox for Android 54, Client objects were not returned in the most recent focus order as required by the specification.
Firefox for Android – Full support
Firefox for Android 54 (Release date: 2017-06-13)
footnote Full support
Opera Android – Full support
Opera Android 29 (Release date: 2015-04-28)
footnote Full support
Safari on iOS – Full support
Safari on iOS 11.3 (Release date: 2018-03-29)
footnote Full support
Samsung Internet – Full support
Samsung Internet 4 (Release date: 2016-03-11)
footnote
footnote Client objects returned in most recent focus order.
WebView Android – Full support
WebView Android 42 (Release date: 2015-04-15)
footnote
footnote Client objects returned in most recent focus order.
WebView on iOS – No support
WebView on iOS
footnote No support
options.includeUncontrolled parameter
Chrome – Full support
Chrome 42 (Release date: 2015-04-14)
footnote
footnote Client objects returned in most recent focus order.
Edge – Full support
Edge 17 (Release date: 2018-04-30)
footnote
footnote Client objects returned in most recent focus order.
Firefox – Full support
Firefox 44 (Release date: 2016-01-26)
footnote Full support
Opera – Full support
Opera 38 (Release date: 2016-06-08)
footnote Full support
Safari – Full support
Safari 11.1 (Release date: 2018-04-12)
footnote Full support
Chrome Android – Full support
Chrome Android 42 (Release date: 2015-04-15)
footnote
footnote Client objects returned in most recent focus order.
Firefox for Android – Full support
Firefox for Android 44 (Release date: 2016-01-26)
footnote Full support
Opera Android – Full support
Opera Android 41 (Release date: 2016-10-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 11.3 (Release date: 2018-03-29)
footnote Full support
Samsung Internet – Full support
Samsung Internet 4 (Release date: 2016-03-11)
footnote
footnote Client objects returned in most recent focus order.
WebView Android – Full support
WebView Android 42 (Release date: 2015-04-15)
footnote
footnote Client objects returned in most recent focus order.
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
See implementation notes.
Has more compatibility info.