Window.onbeforeinstallprompt

The Window.onbeforeinstallprompt property is an event handler for processing a beforeinstallprompt, which is dispatched on devices when a user is about to be prompted to "install" a web application. Its associated event may be saved for later and used to prompt the user at a more suitable time. 

Syntax

window.addEventListener("beforeinstallprompt", function(event) { ... });
window.onbeforeinstallprompt = function(event) { ...};

Example

The following example uses the beforeinstallprompt event handler to make an install button operable, by using the event inside a click handler.

window.addEventListener("beforeinstallprompt", function(e) {
  e.preventDefault(); // Prevents immediate prompt display

  // Shows prompt after a user clicks an "install" button
  installButton.addEventListener("click", function(e) {
    e.prompt();
  });

  installButton.hidden = false; // Make button operable
});

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 45 No support No support 32 No support
Feature Android Webview Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support 45 45 No support No support 32 No support 45.0 [1]

Specifications

Specification Status Comment
Web App Manifest
The definition of 'Window.onbeforeinstallprompt' in that specification.
Working Draft Initial specification.

See Also

Document Tags and Contributors

 Contributors to this page: samthor, jpmedley, chrisdavidmills, teoli
 Last updated by: samthor,