files/en-us/web/api/clients/matchall/index.md
{{APIRef("Service Workers API")}}{{AvailableInWorkers("service")}}
The matchAll() method of the {{domxref("Clients")}}
interface returns a {{jsxref("Promise")}} for a list of service worker
{{domxref("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.
matchAll()
matchAll(options)
options {{optional_inline}}
includeUncontrolled
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
"window", "worker", "sharedworker", and
"all". The default is "window".A {{jsxref("Promise")}} that resolves to an array of {{domxref("Client")}} objects. In Chrome 46/Firefox 54 and later, this method returns clients in most recently focused order, correct as per spec.
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}}
{{Compat}}