API in Installation
beforeinstallprompt and missing install banners
Published Updated
beforeinstallprompt is a window event that lets you defer Chromium’s install prompt until a user clicks your install button. The browser fires it once the page meets its installability criteria. The handler calls preventDefault() to hold back the browser’s own banner, keeps the BeforeInstallPromptEvent, and later calls prompt() from a click so the install dialog opens at a moment the page chooses. Browser-compat-data lists it from Chrome 44 (Android included), Edge 79, and Samsung Internet 5.0; Safari (iOS and macOS) and Firefox do not, and install only from their own menus (BCD api.BeforeInstallPromptEvent).
Syntax
Section titled “Syntax”window.addEventListener('beforeinstallprompt', (event) => { event.preventDefault(); // keep the browser's banner from showing now deferred = event; // one-shot: usable for a single prompt()});
await deferred.prompt(); // from a user gestureconst { outcome, platform } = await deferred.userChoice;
window.addEventListener('appinstalled', () => { /* installed from any UI */ });BCD api.BeforeInstallPromptEvent.prompt records the { outcome, platform } return value from Chrome 76. In Chrome 44 through 75, prompt() resolves without a value, while userChoice is recorded from Chrome 44. Read userChoice when code covers the full event support range. appinstalled fires on window whether the install came from prompt(), from the address-bar icon, or from the browser menu.
Members
Section titled “Members”BeforeInstallPromptEvent extends Event with two members; appinstalled is a plain Event.
| Member | Type | Description |
|---|---|---|
platforms |
readonly string[] |
The install targets the browser offers, for example ["web"] on desktop or ["web", "play"] on Android when the manifest lists a Play app with prefer_related_applications. |
userChoice |
Promise<{ outcome, platform }> |
Resolves after the dialog closes. outcome is "accepted" or "dismissed"; platform is the chosen entry of platforms, or "" when dismissed. |
prompt() |
Promise<void | { outcome, platform }> |
Shows the browser’s install dialog. BCD records the result object from Chrome 76 and an empty resolution in Chrome 44 through 75. Allowed once per event and only with transient user activation. |
preventDefault() |
inherited | Stops the browser from showing its own install banner (the Android mini-infobar) for this installability check. |
When the event fires
Section titled “When the event fires”The page must be served over HTTPS (or from localhost) and link a manifest with name or short_name, start_url, a display other than browser, and icons that include 192 px and 512 px sizes. Chrome dropped the service-worker requirement for installing from the browser menu in Chrome 108 on Android and Chrome 112 on desktop, supplying a default offline page; the Chrome team’s post on that change notes that the heuristic behind beforeinstallprompt still looked for a fetch handler, so a page without a service worker can be installable from the menu and still not receive the event. Chrome also withholds the event while the app is already installed and until its engagement heuristics are met.
Exceptions
Section titled “Exceptions”prompt() rejects; nothing else in this API throws.
NotAllowedError:prompt()was called without transient user activation, for example on page load or from a timer. Chromium’s message isThe prompt() method must be called with a user gesture.InvalidStateError:prompt()was called a second time on the same event, or the event’s underlying banner request is no longer valid (the page navigated, or the browser already showed its own UI).
In Safari and Firefox the event does not fire, so there is no event object to misuse; code that assumes a prompt will come simply leaves its button hidden.
Why the install banner is not shown
Section titled “Why the install banner is not shown”Calling preventDefault() does not display an install dialog. In a custom install flow, save the event, reveal your own install button, and call the saved event’s prompt() from that button’s click handler. This is the sequence in Chrome’s custom install guidance. If you cancel the default handling but never call prompt(), the custom flow has no step that opens the dialog.
Separate these cases before changing the manifest:
| What you see | What to check | Next step |
|---|---|---|
The event fired, but the banner is not shown after preventDefault() |
Is the event saved, and does a visible button call its prompt()? |
Connect the saved event to the click handler in the example below. |
prompt() rejects |
Was it called from a user action, and has this event already been used? | Call it directly from the click handler; do not reuse a consumed event. |
| The event never fires | Does this browser implement the API, and does the site meet its installability requirements? | Check installability criteria and browser support. |
| The visitor is using iOS Safari | Safari does not implement this event | Offer Add to Home Screen instructions instead of waiting for beforeinstallprompt. |
MDN’s prompt() reference documents the user-action and single-use requirements. When the user dismisses a dialog, keep the install button hidden until a new event arrives. A rejected promise should be handled in your UI; retrying the same event in a timer is not a replacement for a new user action and a usable event.
The install demo exposes the flow for comparison. Check that your page receives the event and reaches the click handler independently: an install button hidden by application state is a different problem from a browser that never supplies the event.
Examples
Section titled “Examples”Both examples run in the page; the service worker and manifest are assumed to be in place.
Deferring the event and prompting from a button
Section titled “Deferring the event and prompting from a button”The handler stores the event and reveals a button. The click handler calls prompt(), reads the outcome, and clears the stored event because it is single-use. The appinstalled listener hides the button for installs that came from the browser’s own UI.
let deferred = null;const button = document.querySelector('#install');
window.addEventListener('beforeinstallprompt', (event) => { event.preventDefault(); deferred = event; button.hidden = false;});
button.addEventListener('click', async () => { if (!deferred) return; const promptEvent = deferred; deferred = null; // prevent a second call while awaiting await promptEvent.prompt(); const { outcome, platform } = await promptEvent.userChoice; button.hidden = true; if (outcome === 'accepted') analytics.track('install_accepted', { platform });});
window.addEventListener('appinstalled', () => { deferred = null; button.hidden = true;});Chrome applies a cool-down after dismissal before firing beforeinstallprompt again for the same site. Showing the button after a completed task keeps the page’s single event for a moment when acceptance is more likely than at first paint.
Detecting support and guiding Safari users instead
Section titled “Detecting support and guiding Safari users instead”Safari does not fire the event. The page can still detect whether it is already running installed (display-mode: standalone, or the legacy navigator.standalone on iOS) and, if not, show Share-sheet instructions in place of a button that would not appear.
const installed = window.matchMedia('(display-mode: standalone)').matches || navigator.standalone === true; // iOS Safari only
const supportsPrompt = 'onbeforeinstallprompt' in window;
if (installed) { hideAllInstallUi();} else if (!supportsPrompt) { // Safari and Firefox: no event will come. Explain the manual route. showHint(/iPhone|iPad/.test(navigator.userAgent) ? 'Tap Share, then "Add to Home Screen".' : 'Use your browser menu to install this app.');}// Chromium: wait for beforeinstallprompt before showing anything.'onbeforeinstallprompt' in window is true in every Chromium browser that implements the event, so the hint branch runs only where no event will come; the Chromium branch keeps the install UI hidden until the event confirms installability.
See also
Section titled “See also”-
Web Manifest Application Information and incubations: BeforeInstallPromptEvent (wicg.github.io)
-
Changes to the installability criteria (developer.chrome.com)
Specifications
| Specification | Status |
|---|---|
| Install Prompt (beforeinstallprompt) | WICG draft |
- Legend
- Yes
- Partial
- Flag
- No
- Unknown
| Browser / Platform | Support | Versions | Confidence | Source | Notes |
|---|---|---|---|---|---|
| Chrome (Desktop)# | Yes | 44 | high | source | — |
| Chrome (Android)# | Yes | 44 | high | source | 1 |
| Edge (Desktop)# | Yes | 79 | high | source | 2 |
| Firefox (Desktop)# | No | — | high | source | 3 |
| Firefox (Android)# | No | — | high | source | 45 |
| Safari (macOS)# | No | — | high | source | 6 |
| Safari (iOS)# | No | — | high | source | 78 |
| Samsung Internet# | Yes | 5.0 | high | source | — |
| WebView (Android)# | Yes | 44 | high | source | 9 |
- Derived by browser-compat-data mirroring from Chrome.
- Derived by browser-compat-data mirroring from Chrome.
- No Firefox support is recorded in browser-compat-data.
- No Firefox for Android support is recorded in browser-compat-data.
- Derived by browser-compat-data mirroring from Firefox.
- No Safari support is recorded in browser-compat-data.
- No Safari on iOS support is recorded in browser-compat-data.
- Derived by browser-compat-data mirroring from Safari.
- Derived by browser-compat-data mirroring from Chrome Android.
Cite this table
Install Prompt (beforeinstallprompt) compatibility data — OpenPWA · Verified 2026-10-20 · CC BY 4.0 · JSON
When reusing compatibility data, keep the attribution, identify your changes and check each row’s original source. This citation excludes market-share and reach figures, which use CC BY-SA 4.0.