Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. ServiceWorkerContainer
  4. getRegistration()

ServiceWorkerContainer: getRegistration() 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⁩.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

Note: This feature is available inWeb Workers.

ThegetRegistration() method of theServiceWorkerContainer interface gets aServiceWorkerRegistration object whose scope URL matches the providedclient URL. The method returns aPromise that resolves toaServiceWorkerRegistration orundefined.

Syntax

js
getRegistration()getRegistration(clientURL)

Parameters

clientURLOptional

The registration whose scope matches this URL will be returned. Relative URLs are resolved with the current client as the base. If this parameter is not provided, the current client's URL will be used by default.

Return value

APromise that resolves to aServiceWorkerRegistrationobject orundefined.

Examples

js
navigator.serviceWorker.getRegistration("/app").then((registration) => {  if (registration) {    document.querySelector("#status").textContent =      "ServiceWorkerRegistration found.";  }});

Specifications

Specification
Service Workers Nightly
# navigator-service-worker-getRegistration

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp