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
— if set totrue
, 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 isfalse
. type
: Sets the type of clients you want matched. Available values are"window"
,"worker"
,"sharedworker"
, and"all"
. The default is"window"
.
- A
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
Specification | Status | Comment |
Service WorkersThe definition of 'Clients: matchall' in that specification. | Working Draft | Initial definition |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome Full support 47 Full support 47 Notes' |
Edge Full support ≤79 Full support ≤79 Notes' |
Firefox Full support 44 Full support 44 Notes' Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API. Full support 54 Notes' |
IE
No support No |
Opera
Full support 32 |
Safari
No support No |
WebView Android Full support 47 Full support 47 Notes' |
Chrome Android Full support 47 Full support 47 Notes' |
Firefox Android Full support 44 Full support 44 Full support 54 Notes' |
Opera Android
Full support 32 |
Safari iOS
No support No |
Samsung Internet Android Full support 4.0 Full support 4.0 Notes' |
|
Chrome Full support 47 Full support 47 Notes' |
Edge Full support ≤79 Full support ≤79 Notes' |
Firefox Full support 45 Full support 45 Notes' |
IE
No support No |
Opera
Full support 38 |
Safari
No support No |
WebView Android Full support 47 Full support 47 Notes' |
Chrome Android Full support 47 Full support 47 Notes' |
Firefox Android Full support 45 Full support 45 Notes' |
Opera Android
Full support 41 |
Safari iOS
No support No |
Samsung Internet Android Full support 5.0 Full support 5.0 Notes' |
Legend
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.'
- Experimental. Expect behavior to change in the future.
- See implementation notes.'
- See implementation notes.
Clients.matchAll() by Mozilla Contributors is licensed under CC-BY-SA 2.5.