Non-standard: This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
The BeforeInstallPromptEvent is the interface of the beforeinstallprompt event fired at the Window object before a user is prompted to "install" a website to a home screen on mobile.
Returns an array of string items 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.
Allows a developer to show the install prompt at a time of their own choosing. This method returns a Promise.
Example
window.addEventListener("beforeinstallprompt",(e)=>{// log the platforms provided as options in an install prompt
console.log(e.platforms);// e.g., ["web", "android", "windows"]
e.userChoice.then((choiceResult)=>{
console.log(choiceResult.outcome);// either "accepted" or "dismissed"}, handleError);});
Browser compatibility
Desktop
Mobile
Chrome
Edge
Firefox
Internet Explorer
Opera
Safari
WebView Android
Chrome Android
Firefox for Android
Opera Android
Safari on IOS
Samsung Internet
BeforeInstallPromptEvent
44
79
No
No
31
No
44
44
No
32
No
5.0
BeforeInstallPromptEvent
44
79
No
No
31
No
44
44
No
32
No
5.0
platforms
44
79
No
No
31
No
44
44
No
32
No
5.0
prompt
76The object returned by the promise returns a property called outcome instead of userChoice.44–76Resolved with an empty promise.
79The object returned by the promise returns a property called outcome instead of userChoice.
No
No
63The object returned by the promise returns a property called outcome instead of userChoice.31–63Resolved with an empty promise.
No
76The object returned by the promise returns a property called outcome instead of userChoice.44–76Resolved with an empty promise.
76The object returned by the promise returns a property called outcome instead of userChoice.44–76Resolved with an empty promise.
No
54The object returned by the promise returns a property called outcome instead of userChoice.32–54Resolved with an empty promise.