Installation
Progressive Web Apps can be installed to the home screen on mobile devices and desktop on laptops and desktop
computers. On Chromium based browsers, the beforeinstallprompt
event is fired when the web app is
eligible to be installed. This event will display a native install dialog that includes a button to install the
web app.
Demo
Click the "Install" button below to install this web app. In supporting browsers, the native install dialog will appear and in non-supporting browsers, a bottom sheet with instructions how to install this web app will be displayed.
Handling the install prompt
A best-practice is to defer the display of the install dialog using event.preventDefault()
and
displaying it when it makes more sense, for example, when the user explicitly clicks a button to install the web
app.
For a web app to be eligible to be installed, it must meet some technical requirements:
- The web app must have a manifest.json file
- The web app must be served over https
The manifest.json file tells the browser how the PWA should appear and behave on the device and for a web app to be installable it must have the following required members:
name
orshort_name
icons
must contain a 192px and a 512px iconstart_url
display
and/ordisplay_override
prefer_related_applications
must befalse
or not present
For a description of these members, see the Web app manifest reference
In addition to these required members, a description of the web app and an optional array of screenshots can be included that will be shown in the native install dialog, bringing the install process closer to that of native apps.
Screenshots must follow these criteria:
- Width and height must be at least 320px and at most 3,840px.
- The maximum dimension can't be more than 2.3 times as long as the minimum dimension.
- All screenshots with the same form factor value must have identical aspect ratios.
- Only JPEG and PNG image formats are supported.
- Only eight screenshots will be shown. If more are added, the user agent simply ignores them.
In addition, all screenshots must have a form_factor
property that indicates whether the screenshot is
displayed on mobile devices (value is "narrow") or desktop devices (value is "wide").
Documentation
Making Progressive Web Apps Installable on MDNBrowser support
The beforeinstallprompt
event and the screenshots
member of the manifest.json file are
supported in Chromium based browsers, including Chrome, Edge, and Opera. For other browsers, you need to display
a dialog with instructions on how to install the web app.