Concept Explanation
Imagine a website that has a "Home Screen Icon," works without an internet connection, and sends you push notifications. That's a PWA. It's built with standard web technologies (HTML, CSS, JS) but feels like a native mobile app.
The point is not to imitate native apps for fun. It is to skip the app store entirely. No review queue, no 30% cut, no separate iOS and Android codebases, no asking a user to download 80MB before they can try your product. They tap a link, and if they like it, they add it to their home screen.
The word progressive is the important one. A PWA is a normal website first. On an old browser it is just a website. On a modern one it gains installability, offline support and background sync. Nothing breaks; capability accumulates.
The Three Requirements
- HTTPS: Security is mandatory for the powerful features of a PWA.
- Web App Manifest: A JSON file that tells the phone how the app should look (name, icons, colors).
- Service Worker: A script that runs in the background and handles the "Offline" magic.
Miss any one of the three and the install prompt never appears. Chrome's "Application" panel will tell you exactly which piece is absent.
Syntax or Core Structure
The minimum viable PWA
<!-- index.html -->
<link rel="manifest" href="/manifest.webmanifest" />
<meta name="theme-color" content="#7c3aed" />
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js');
}
</script>
{
"name": "Recipe Keeper",
"short_name": "Recipes",
"start_url": "/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#7c3aed",
"icons": [
{ "src": "/icon-192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "/icon-512.png", "sizes": "512x512", "type": "image/png" }
]
}
That is genuinely all it takes to become installable.
Real World Example
Twitter Lite is the case study everyone cites. Twitter shipped a PWA that came in under 1MB against a native app of roughly 25MB, and reported large jumps in pages per session and tweets sent, particularly in markets where data is expensive and phones are older. Starbucks did the same for ordering: a PWA a fraction of the size of the iOS app, usable offline so you can browse the menu on a train with no signal.
The common thread is not that PWAs are faster than native. It is that they remove the install barrier.
Key Features
- Installable: gets a home-screen icon and its own window with no browser chrome.
- Offline-capable: the service worker can serve cached responses when the network is gone.
- Re-engageable: push notifications and background sync, subject to user permission.
- Linkable: still just a URL, so it is shareable and indexable.
Common Mistakes
- Testing over plain HTTP. Service workers are blocked on anything but HTTPS and
localhost. Deploy to a real HTTPS host before you conclude your code is broken. - Forgetting the 512px icon. Chrome needs both 192 and 512 to consider the app installable, and a
maskableicon if you want a decent shape on Android. - Treating iOS as equivalent. Safari supports the basics but has historically lagged on push and background sync, and it evicts storage from unused sites. Test on a real iPhone.
- Expecting offline for free. A registered service worker that does nothing gives you no offline support at all. You still have to write the caching.
- Shipping a stale service worker. Without a version bump and an update path, returning users can be pinned to an old build indefinitely.
Best Practices
- Build the site properly first, then add PWA features. A fast site with a broken service worker is worse than a fast site with none.
- Run the Lighthouse "Installable" audit; it names each missing requirement precisely.
- Ask for notification permission only after the user has done something meaningful, never on first paint.
- Give offline an honest UI. Tell the user what is cached and what needs a connection.
Practice Exercises
- The Icon Hunter: Go to any site like Starbucks.com or Twitter.com. Look for the "Install" icon in the URL bar. If it's there, it's a PWA!
- The Manifest Maker: Research the
manifest.jsonfile. List 3 properties that are required for a site to be "Installable." - Standalone Mode: Research what
display: "standalone"does to the browser UI on a phone.