PWA
Progressive Web App
In short
A PWA is a website built with modern web APIs so it can be installed on a device, work offline, and behave much like a native app from a single codebase.
What is a PWA?
A progressive web app is a regular website that uses a set of browser features to feel more like an installed app. Users can add it to their home screen or desktop, open it in its own window without the browser's address bar, and in many cases keep using it with a poor or missing internet connection.
Three pieces make this work. The site must be served over HTTPS; a web app manifest, a small JSON file, describes the app's name, icons, colors, and start URL; and a service worker, a script the browser runs in the background separate from the page, can intercept network requests, cache files for offline use, and receive push notifications. The word progressive means the app still works as a normal website in browsers that lack some of these features.
Think of a PWA as a website that learned to pack a suitcase: it keeps copies of what it needs so it can keep working away from the network. PWAs are popular for news sites, online stores, productivity tools, and any app that needs to reach many devices without separate iOS and Android versions.
A PWA is not the same as a native app. It runs in the browser engine and can use only the device features the browser exposes, and support varies by platform, with some features, such as background sync, more limited on iOS than on Android and desktop. PWAs can sometimes be listed in app stores through wrapper tools, but they are still web apps underneath.
Key takeaways
- A PWA is a website that can be installed and used like an app.
- It needs HTTPS, a web app manifest, and a service worker.
- Service workers cache files so the app can work offline.
- One codebase serves browsers, phones, and desktops.
- Available device features depend on the browser and platform.
Example
// main.js: register the service worker if the browser supports it
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/sw.js");
}
// sw.js: cache key files at install, then serve them when offline
self.addEventListener("install", (event) => {
event.waitUntil(
caches.open("v1").then((cache) => cache.addAll(["/", "/app.css", "/app.js"]))
);
});
self.addEventListener("fetch", (event) => {
event.respondWith(caches.match(event.request).then((hit) => hit || fetch(event.request)));
});Readers ask
What is the difference between a PWA and a native app?
A native app is written for a specific platform such as iOS or Android and installed from an app store, with full access to device features. A PWA is built with web technologies, runs in the browser engine, and can be installed straight from a website, but it can use only the features the browser allows.
Do PWAs work on iPhone?
Yes. On iOS and iPadOS, users can add a PWA to the home screen from the browser's Share menu, and home screen web apps can receive push notifications. Some features available on Android and desktop, such as background sync, are more limited.
What is a service worker?
A service worker is a JavaScript file that the browser runs in the background, separate from the web page. It can intercept network requests, serve cached responses when the device is offline, and handle push notifications.
See also
- JavaScriptWeb Development, p. 24JavaScript is the programming language that runs in web browsers to make pages interactive, and it also runs on servers through runtimes like Node.js.
- HTTPSSecurity, p. 17HTTPS is the secure version of HTTP that encrypts traffic between a browser and a website with TLS, protecting data from eavesdropping and tampering.
- SPAWeb Development, p. 41An SPA is a web application that loads a single HTML page and then updates content with JavaScript, so moving between views does not reload the page.
- Responsive DesignWeb Development, p. 38Responsive design is an approach to building web pages whose layout, images, and text adapt automatically to any screen size, from phones to large monitors.
- CacheBackend & APIs, p. 8A cache is a fast, temporary storage layer that keeps copies of frequently used data so later requests can be served quickly without repeating slow work.
- JSONBackend & APIs, p. 25JSON is a lightweight, text-based format for storing and exchanging structured data as key-value pairs and lists, readable by both humans and machines.
- Progressive EnhancementWeb Development, p. 34Progressive enhancement is a web design strategy that starts with a basic page that works for everyone, then adds richer features where browsers support them.
Spotted a mistake or something missing on this page?Suggest an edit