Demos

Web Install API - navigator.install()

Manifest-URL design

This directory contains demos that showcase the use of navigator.install, an API under development to allow web contents to install other web apps.

Demos

How to use it

Detect support

if ('install' in navigator) {
  // navigator.install is supported.
} else {
  // navigator.install is not supported.
}

Install the currently loaded document

install() requirements:

const installApp = async () => {
  if (!navigator.install) return; // API not supported.

  try {
    await navigator.install();
    console.log('Install flow completed successfully');
  } catch (err) {
    if (err.name === 'AbortError') {
      console.log('Install was cancelled or could not be completed');
    }
  }
};

Install a background document

To install a document that’s not the current document, use an options object with either manifest, or both manifest and manifestId.

install({ manifest }) requirements:

const installApp = async (manifest) => {
  if (!navigator.install) return; // API not supported.

  try {
    await navigator.install({ manifest });
    console.log('Install flow completed successfully');
  } catch (err) {
    if (err.name === 'AbortError') {
      console.log('Install was cancelled or could not be completed');
    } else if (err.name === 'DataError') {
      console.log('The manifest or manifestId is invalid');
    }
  }
};

install({ manifest, manifestId }) requirements:

You can find the computed ID by going to Application > Manifest > Identity > Computed App ID in DevTools.

const installApp = async (manifest, manifestId) => {
  if (!navigator.install) return; // API not supported.

  try {
    await navigator.install({ manifest, manifestId });
    console.log('Install flow completed successfully');
  } catch (err) {
    if (err.name === 'AbortError') {
      console.log('Install was cancelled or could not be completed');
    } else if (err.name === 'DataError') {
      console.log('The manifest or manifestId is invalid');
    }
  }
};

Handle installation errors

The promise returned by navigator.install() resolves when the install flow completes successfully. It rejects with a DOMException when the flow doesn’t complete:

const button = document.querySelector('#install');

button.addEventListener('click', async () => {
  try {
    await navigator.install({
      manifest: 'https://foo.com/manifest.json',
      manifestId: 'https://foo.com/home',
    });
    console.log('Install flow completed successfully');
  } catch (err) {
    switch (err.name) {
      case 'AbortError':
        console.log('Install was cancelled or could not be completed');
        break;
      case 'DataError':
        console.log('The manifest or manifestId is invalid');
        break;
      case 'InvalidStateError':
      case 'NotAllowedError':
      case 'NotFoundError':
      case 'TypeError':
        console.error(`Install flow failed: ${err.name}`);
        break;
      default:
        console.error('Install flow failed unexpectedly', err);
    }
  }
});

Test the feature locally

To test the manifest-URL design locally, in your browser only, use a Chromium-based browser version 153 or later and enable the Web App Installation API experiment:

  1. In the browser, open a new tab and go to about://flags/#web-app-installation-api.
  2. Enable the Web App Installation API flag.
  3. Click the Restart button in the bottom right. The browser restarts.

Provide feedback

Your feedback is crucial to the development of this feature. Please share feedback to:

To share feedback, open a new issue on the MSEdgeExplainers repo.

We look forward to hearing from you!

See also