# getInstalledRelatedApps()

> How navigator.getInstalledRelatedApps() reports which entries of the manifest's related_applications are installed on the device, the verification each platform demands, the empty-array and InvalidStateError cases, and a fallback.

The `navigator.getInstalledRelatedApps()` method reports which apps listed in the calling web app's manifest `related_applications` are installed on the device. Use the result to hide an install button or deep-link into a native counterpart. Chrome 84 and Samsung Internet 14 on Android report Play apps and installed PWAs; Chrome 85, Edge 85, and Opera 71 on Windows report UWP apps, and BCD notes that desktop Chrome resolves with an empty array on other platforms. The Chrome capability guide adds that desktop Chrome and Edge 140 or later (Windows, macOS, Linux, ChromeOS) can check a PWA installed in the same scope. Firefox and Safari have not implemented the method (BCD `api.Navigator.getInstalledRelatedApps`).

## Syntax

```js
const apps = await navigator.getInstalledRelatedApps();
```

The method is `[SecureContext]`, so it is absent on plain HTTP origins, and it is defined only on `Navigator`, not on `WorkerNavigator`.

## Parameters

None. The promise fulfils with an array of `RelatedApplication` dictionaries, one per installed match, each carrying the fields below.

| Field | Type | Description |
|---|---|---|
| `platform` | `string` | The store or ecosystem: `"play"`, `"windows"`, `"webapp"`, `"chrome_web_store"`, `"chromeos_play"`, `"f-droid"`, or `"amazon"`. Copied from the manifest entry. |
| `id` | `string`, optional | The platform-specific identifier (Android package name, UWP package family name). |
| `url` | `string`, optional | The entry's `url` from the manifest; for `"webapp"` it is the related PWA's manifest URL. |
| `version` | `string`, optional | The installed version where the platform exposes one. |

A match requires both halves of the relationship: the manifest entry on the calling site, and a declaration on the other app pointing back. An Android app does so with Digital Asset Links (an `asset_statements` entry in its resources that names the website); a UWP app does so with URI handlers; a related PWA does so with a `related_applications` entry of its own when the caller is inside its scope. For a PWA outside the caller's scope, the Chrome guide documents `assetlinks.json` with `delegate_permission/common.query_webapk` and lists it as Android only.

## Exceptions

- `InvalidStateError`: the method was called from a document that is not the top-level browsing context, such as an `<iframe>`, or from a document that is no longer fully active (spec, "getInstalledRelatedApps()" steps 1 and 2).
- `TypeError`: thrown synchronously in Firefox and Safari, where `navigator.getInstalledRelatedApps` is `undefined`, and on insecure origins in every browser.

An empty array is not an error. It is the result when `related_applications` is missing or when no listed entry matches an installed app. Entries are matched one by one, so an entry whose back-reference (asset links or URI handler) fails verification, or a PWA that a page outside its scope asks about on desktop, drops out of the result. BCD records that Chrome checks UWP apps on Windows and resolves with an empty array on other platforms, and web.dev lists same-scope PWAs as checkable on desktop from Chrome and Edge 140.

:::note
The browser compatibility data on MDN lists `navigator.getInstalledRelatedApps` as unsupported in Firefox and Safari, so the property is `undefined` there ([BCD](https://github.com/mdn/browser-compat-data/blob/main/api/Navigator.json)). Chrome's capability guide says only the first three apps declared in the manifest are taken into account, and that desktop Chrome and Edge 140 or later can check a PWA installed in the same scope, where each `related_applications` entry needs the app's `id` ([web.dev](https://web.dev/articles/get-installed-related-apps)).
:::

## Examples

Both examples assume a manifest whose `related_applications` names the Android app `com.example.app` and the site's own PWA.

### Hiding the install button when the Play app is present

The manifest declares the relationship; the page checks it before deciding whether to show a web install affordance. Because the method only answers for the first three entries, list the apps that matter most first.

```json
{
  "related_applications": [
    { "platform": "play", "id": "com.example.app",
      "url": "https://play.google.com/store/apps/details?id=com.example.app" },
    { "platform": "webapp", "url": "https://example.com/manifest.json" }
  ],
  "prefer_related_applications": false
}
```

```js
async function decideInstallUi() {
  const apps = await navigator.getInstalledRelatedApps();
  if (apps.some((app) => app.platform === 'play')) {
    installButton.hidden = true;             // the native app is already there
    openInAppLink.hidden = false;            // offer the deep link instead
  } else if (apps.some((app) => app.platform === 'webapp')) {
    installButton.hidden = true;             // this PWA is installed from another browser or profile
  }
}
```

Keep `prefer_related_applications` at `false` unless the native app should replace the PWA: when it is `true`, Chrome's install UI offers the store listing instead of installing the web app.

### Detecting support and falling back to the install prompt

Where the method is absent or returns nothing, the page has no installed-state signal from other apps and should fall back to its normal install flow and to the `display-mode` check for its own installed state.

```js
async function relatedAppInstalled() {
  if (!('getInstalledRelatedApps' in navigator)) return false;   // Firefox, Safari, HTTP
  try {
    const apps = await navigator.getInstalledRelatedApps();
    return apps.length > 0;
  } catch (error) {
    if (error.name === 'InvalidStateError') return false;        // called inside an iframe
    throw error;
  }
}

if (!(await relatedAppInstalled())) {
  showInstallAffordance();   // beforeinstallprompt flow, or Share-sheet instructions on iOS
}
```

The `false` branch treats an unavailable result as no related app installed. This can show an install button to a user who already has the native app.

## See also

- [Get Installed Related Apps API specification](https://wicg.github.io/get-installed-related-apps/spec/) (wicg.github.io)
- [Is your app installed? getInstalledRelatedApps() will tell you!](https://developer.chrome.com/docs/capabilities/get-installed-related-apps) (developer.chrome.com)
- [getInstalledRelatedApps() browser support](/compatibility/get-installed-related-apps/)
- [`related_applications` manifest member](/reference/manifest/related-applications/)
- [beforeinstallprompt event](/reference/installation/install-prompt/)
- [The N+1 install problem](/reference/installation/n-plus-one/)