Window: beforeinstallprompt event

The beforeinstallprompt event fires on devices when a user is about to be prompted to "install" a web application. It may be saved for later and used to prompt the user at a more suitable time.


Use the event name in methods like addEventListener(), or set an event handler property.

addEventListener('beforeinstallprompt', (event) => { });

onbeforeinstallprompt = (event) => { };

Event type

Event properties

Inherits properties from its parent, Event.

BeforeInstallPromptEvent.platforms Read only

Returns an array of strings containing the platforms on which the event was dispatched. This is provided for user agents that want to present a choice of versions to the user such as, for example, "web" or "play" which would allow the user to choose between a web version or an Android version.

BeforeInstallPromptEvent.userChoice Read only

Returns a Promise that resolves to a string containing either "accepted" or "dismissed".


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

window.addEventListener("beforeinstallprompt", (beforeInstallPromptEvent) => {
  beforeInstallPromptEvent.preventDefault(); // Prevents immediate prompt display

  // Shows prompt after a user clicks an "install" button
  installButton.addEventListener("click", (mouseEvent) => {
    // you should not use the MouseEvent here, obviously

  installButton.hidden = false; // Make button operable

Browser compatibility

BCD tables only load in the browser

See also