# Progressive web app

A progressive web application (PWA), or progressive web app, is a type of web app that can be installed on a device as a standalone application. PWAs are installed using the offline cache of the device's web browser.
PWAs were introduced from 2016 as an alternative to native (device-specific) applications, with the advantage that they do not require separate bundling or distribution for different platforms. They can be used on a range of different systems, including desktop and mobile devices. Publishing the app to digital distribution systems, such as the Apple App Store, Google Play, or the Microsoft Store on Windows, is optional.
Because a PWA is delivered in the form of a webpage or website built using common web technologies including HTML, CSS, JavaScript, and WebAssembly, it can work on any platform with a PWA-compatible browser. As of 2021, PWA features are supported to varying degrees by Google Chrome, Apple Safari, Firefox for Android, and Microsoft Edge but not by Firefox for desktop.

## History
### Predecessors

At Apple's Worldwide Developers Conference in 2007, Steve Jobs announced that the iPhone would "run applications created with Web 2.0 Internet standards". No software development kit (SDK) was required, and the apps would be fully integrated into the device through the Safari browser engine. This model was later switched to the App Store, as a means of appeasing frustrated developers. In October 2007 Jobs announced that an SDK would be launched the following year. As a result, although Apple continued to support web apps, the vast majority of iOS applications shifted toward the App Store.
Beginning in the early 2010s dynamic web pages allowed web technologies to be used to create interactive web applications. Responsive web design, and the screen-size flexibility it provides have made PWA development more accessible. Continued enhancements to HTML, CSS, and JavaScript allowed web applications to incorporate greater levels of interactivity, making native-like experiences possible on a website.
In 2013, Mozilla released Firefox OS. It was intended to be an open-source operating system for running web apps as native apps on mobile devices. Firefox OS was based on the Gecko rendering engine with a user interface called Gaia, written in HTML5. The development of Firefox OS ended in 2016, and the project was completely discontinued in 2017, although a fork of Firefox OS was used as the basis of KaiOS, a feature phone platform.

### Initial introduction

In 2015, designer Frances Berriman and Google Chrome engineer Alex Russell coined the term "progressive web apps" to describe apps taking advantage of new features supported by modern browsers, including service workers and web app manifests, that let users upgrade web apps to progressive web applications in their native operating system (OS). Google then put significant efforts into promoting PWA development for Android. Firefox introduced support for service workers in 2016, and Microsoft Edge and Apple Safari followed in 2018, making service workers available on all major systems.
By 2019, PWAs were supported by desktop versions of most browsers, including Microsoft Edge (on Windows) and Google Chrome (on Windows, macOS, ChromeOS, and Linux).
In December 2020, Firefox for desktop abandoned the implementation of PWAs (specifically, removed the prototype "site-specific browser" configuration that had been available as an experimental feature). A Firefox architect noted: "The signal I hope we are sending is that PWA support is not coming to desktop Firefox anytime soon." Mozilla supports PWAs on Android and plans to keep supporting it.

## Browser support

| Browser | Support | Support | Support | Support | Support | Comment |
| Browser | Windows | macOS | Linux | Android | iOS & iPadOS | Comment |
| Chromium-based | Yes | Yes | Yes | Yes | — | Includes Google Chrome, Microsoft Edge, Brave, Opera, Vivaldi, and others. |
| Firefox | No | No | No | Partial | No | |
| Safari | — | Partial | — | — | Partial | |

## Characteristics

Progressive web apps are all designed to work on any browser that is compliant with the appropriate web standards. As with other cross-platform solutions, the goal is to help developers build cross-platform apps more easily than they would with native apps. Progressive web apps employ the progressive enhancement web development strategy.
Some progressive web apps use an architectural approach called the App Shell Model. In this model, service workers store the Basic User Interface or "shell" of the responsive web design web application in the browser's offline cache. This model allows for PWAs to maintain native-like use with or without web connectivity. This can improve loading time, by providing an initial static frame, a layout or architecture into which content can be loaded progressively as well as dynamically.

### Technical criteria

The technical baseline criteria for a site to be considered a progressive web app and therefore capable of being installed by browsers were described by Russell in 2016 and updated since:
* Originate from a secure origin. Served over TLS and have no active mixed content. Progressive web apps must be served via HTTPS to ensure user privacy, security, and content authenticity.
* Register a service worker with a fetch handler. Progressive web apps must use service workers to create programmable content caches. Unlike regular HTTP web cache, which caches content after the first use and then rely on various heuristics to guess when content is no longer needed, programmable caches can explicitly prefetch content in advance before it's used for the first time and explicitly discard it when it is no longer needed. This requirement helps pages to be accessible offline or on low-quality networks.
* Reference a web app manifest. The manifest must contain at least the five key properties: name or short_name, start_url, and display (with a value of standalone, fullscreen or minimal-ui), and icons (with 192 px and a 512 px versions). Information contained in the manifest makes PWAs easily shareable via a URL, discoverable by search engines, and alleviates complex installation procedures (but PWAs may still be listed in a third-party app store). Furthermore, PWAs support native app-style interactions and navigation, including being added to the home screen, displaying splash screens, etc.

## Technologies

There are many technologies commonly used to create progressive web apps. A web application is considered a PWA if it satisfies the installation criteria, thus can work offline and can be added to the device's home screen. To meet this definition, all PWAs require at minimum a manifest and a service worker. Other technologies may be used to store data, communicate with servers or execute code.

### Manifest

The web app manifest is a World Wide Web Consortium (W3C) specification defining a JSON-based manifest (usually labelled manifest.json) to provide developers with a centralized place to put metadata associated with a web application including:
* The name of the web application
* Links to the web app icons or image objects
* The preferred URL to launch or open the web app
* The web app configuration data
* Default orientation of the web app
* The option to set the display mode, e.g. full screen
This metadata is crucial for an app to be added to a home screen or otherwise listed alongside native apps.

#### iOS support

iOS Safari partially implements manifests, while most of the PWA metadata can be defined via Apple-specific extensions to the meta tags. These tags allow developers to enable full-screen display, define icons and splash screens, and specify a name for the application.

### Service workers

A service worker is a web worker that implements a programmable network proxy that can respond to web/HTTP requests from the main document. It is able to check the availability of a remote server, cache content when that server is available, and serve that content to the document later. Service workers, like any other web workers, work separately from the main document context. Service workers can handle push notifications and synchronize data in the background, cache or retrieve resource requests, intercept network requests and receive centralized updates independently of the document that registered them, even when that document is not loaded.
Service workers go through a three-step lifecycle of Registration, Installation and Activation. Registration involves telling the browser the location of the service worker in preparation for installation. Installation occurs when there is no service worker installed in the browser for the web app, or if there is an update to the service worker. Activation occurs when all of the PWA's pages are closed, so that there is no conflict between the previous version and the updated one. The lifecycle also helps maintain consistency when switching among versions of a service worker since only a single service worker can be active for a domain.

### WebAssembly

WebAssembly allows precompiled code to run in a web browser, at near-native speed. Thus, libraries written in languages such as C can be added to web apps. Announced in 2015 and first released in March 2017, WebAssembly became a W3C recommendation on December 5, 2019 and it received the Programming Languages Software Award from ACM SIGPLAN in 2021.

### Data storage

Progressive Web App execution contexts get unloaded whenever possible, so progressive web apps need to store the majority of their long-term internal state (user data, dynamically loaded application resources) in one of the following manners:

#### Web Storage

    Web Storage is a W3C standard API that enables key-value storage in modern browsers. The API consists of two objects, sessionStorage (that enables session-only storage that gets wiped upon browser session end) and localStorage (that enables storage that persists across sessions).

#### Indexed Database API

    Indexed Database API is a W3C standard database API available in all major browsers. The API is supported by modern browsers and enables storage of JSON objects and any structures representable as a string. The Indexed Database API can be used with a wrapper library providing additional constructs around it.

## Comparison with native apps

In 2017, Twitter released Twitter Lite, a PWA alternative to the official native Android and iOS apps. According to Twitter, Twitter Lite consumed only 1–3% of the size of the native apps. Starbucks provides a PWA that is 99.84% smaller than its equivalent iOS app. After deploying its PWA, Starbucks doubled the number of online orders, with desktop users ordering at about the same rate as mobile app users.
A 2018 review published by Forbes, found that users of Pinterest's PWA spent 40% more time on the site compared to the previous mobile website. Ad revenue rates also increased by 44%, and core engagements by 60%. Flipkart saw 60% of customers who had uninstalled their native app return to use the Flipkart PWA. Lancôme saw an 84% decrease in time until the page is interactive, leading to a 17% increase in conversions and a 53% increase in mobile sessions on iOS with their PWA.

## Release via app stores

Since a PWA does not require separate bundling or distribution for different platforms and is available to users via the web, it is not necessary for developers to release it over digital distribution systems like the Apple App Store, Google Play, Microsoft Store, or Samsung Galaxy Store. The major app stores support the publication of PWAs to varying to degrees. Google Play, Microsoft Store, and Samsung Galaxy Store support PWAs, but Apple App Store does not. Microsoft Store publishes some qualifying PWAs automatically (even without app authors' requests) after discovering them via Bing indexing.