Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The prompt() method of the BeforeInstallPromptEvent interface allows a developer to show the install prompt at a time of their own choosing.





Return value

A Promise resolving to an object containing:

userChoice Experimental

A string, either "accepted" or "dismissed", reflecting the BeforeInstallPromptEvent.userChoice property.

platform Non-standard

A string containing the selected platform, reflecting the BeforeInstallPromptEvent.platform property.


let isTooSoon = true;
window.addEventListener("beforeinstallprompt", (e) => {
  if (isTooSoon) {
    e.preventDefault(); // Prevents prompt display
    // Prompt later instead:
    setTimeout(() => {
      isTooSoon = false;
      e.prompt(); // Throws if called more than once or default not prevented
    }, 10000);

  // The event was re-dispatched in response to our request
  // …

Browser compatibility

BCD tables only load in the browser