A Progressive Web App (PWA) is a web application built with web platform technologies that can provide an experience similar to a platform-specific application. According to MDN, a PWA can run on different platforms and devices from a single codebase. It can be installed on a device, work offline and in the background, and interact with the device and other installed applications.
Installation, the web app manifest and the service worker concern different aspects of a PWA. MDN describes installation as making a PWA appear on a device as a persistent application. The W3C Web Application Manifest standard defines the parameters to use when the application launches. The service worker APIs described by MDN can be used for offline operation and background operations.
What does installation mean?
MDN defines installability as one of the distinguishing features of a PWA. An installed PWA appears on the device as a persistent application and can be launched directly from the operating system like other applications. According to web.dev, installed PWAs can be launched from the home screen, dock, taskbar or shelf. Users can search for them on the device and switch between them using the app switcher.
According to the W3C Web Application Manifest standard, a user agent may provide a way for a user to install a web application on their device. When an installed web application is launched, the manifest fields or their defaults are applied. Manifest properties are not applied in this way to a web page opened from a traditional bookmark.
W3C gives examples of how installation can be presented. The application may be shown with a named icon on the home screen or in the launcher. A user agent may also install the application in its own list of bookmarks. MDN also notes that developers can provide an interface within the application to invite users to install it.
What does a web app manifest contain?
According to W3C, an application manifest is a JSON file containing startup parameters and application defaults to be used when a web application launches. These include the application's name, links to its icons and the preferred URL at launch. The manifest can also define the screen orientation, display mode and URL scope of the application.
The fields defined by the standard include name, short_name, icons, id, start_url, scope, display, orientation, theme_color, background_color and shortcuts. W3C states that these fields are optional in the manifest and can appear in any order. The lang field specifies the language for the values of localizable fields; dir defines the default text direction for those fields.
W3C also shows an example in which the manifest is linked using an HTML link element. In the example, the rel value is manifest, and the href value is the name of the manifest file. The same example also contains separate HTML elements for the application name and icons.
Name and icons
name and short_name specify the application's name. According to W3C, the short name can be used where space is limited, such as beneath an icon. When both fields are defined, implementers decide which name to use according to the situation. If one of the fields is missing or is not of the appropriate type, the user agent may use the other.
icons lists icons that can be used to represent the application in different places. W3C's example contains icons of the same size in different formats. The user agent selects an icon from those provided that is suitable for where it will be displayed. An icon's type field can specify its format, and its sizes field can specify its dimensions.
W3C also defines the purpose field for icons. monochrome specifies an icon that can be used where a single-color fill is needed. maskable indicates that the icon was prepared with a mask in mind. any is the default value and can be used where no special purpose is required.
For a maskable icon, the user agent may mask the parts outside the safe area. According to W3C, pixels inside the safe area cannot be made transparent. For a monochrome icon, alpha information is used instead of color information; the user agent may display the icon with a fill color of its choosing.
Launch URL and scope
start_url concerns the URL preferred for opening when the application is launched. According to W3C, start_url is used when an application is launched without a target URL being provided. id represents the identity of the application. The user agent can use this identity to determine whether a manifest describes a separate application or a manifest that replaces one for an installed application.
scope determines which URLs the manifest applies to. In W3C's example, when the scope value is /, the manifest applies to all pages within the origin. When the value is /racer/, pages under that path are in scope; a different path is outside the scope. The standard supports a single scope path.
The browser continues to apply the manifest as the user navigates URLs within scope. When the user navigates outside the scope, the manifest no longer applies and the browser's own defaults take effect. W3C gives the example of displaying the application as a normal web page in a browser tab instead of full screen in this case. How entry into and exit from scope are handled is left to the implementer.