Get AI summaries of any video or article — Sign up free
Progressive Web Apps in 100 Seconds // Build a PWA from Scratch thumbnail

Progressive Web Apps in 100 Seconds // Build a PWA from Scratch

Fireship·
5 min read

Based on Fireship's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

PWAs deliver native-like mobile experiences (offline, push, device interactions) while keeping web distribution benefits and a single code base.

Briefing

Progressive Web Apps (PWAs) let websites behave like native mobile apps—offline support, push notifications, and device features—while keeping the web’s advantages: installability, cross-platform reach (iOS, Android, and browsers), and distribution without app-store revenue cuts. With modern web capabilities now close to native feature parity, a PWA can be installed from a phone’s home screen, run without a connection, and still interact with things like the camera and receive push messages, all from a single code base.

Turning a site into a PWA is less complicated than it sounds, especially when the core requirements are treated as a checklist. Chrome’s Lighthouse audit in DevTools is the starting point: it scores performance and accessibility and flags what’s needed to qualify as a PWA. At minimum, the site must load quickly and be mobile-accessible—most sites already meet that bar. The harder requirement is offline functionality, which typically hinges on a service worker.

A service worker is a background script registered by the browser that can handle caching, background sync, and push notification events. Instead of relying on the page’s single-threaded runtime, the service worker runs independently and can intercept network requests. Implementation is straightforward: check for browser support, register a JavaScript service worker file, and then confirm it’s active in Chrome’s Application tab. From there, the key step is caching the app’s URLs (and other assets) so the content can be served when the network is unavailable. DevTools makes this tangible by letting developers inspect the cache and other background services.

The final piece is a manifest.json file, which provides app metadata—icons, name, and install-related details—and also signals whether a service worker is running correctly. Once Lighthouse requirements are satisfied, the “PWA achievement” appears and the app becomes installable on most native devices. Installable PWAs can also be listed on platforms such as Google Play or the Microsoft Store, extending reach beyond the browser.

For developers, the workflow gets faster with tooling. Workbox is highlighted as a practical library that covers common service-worker tasks with minimal code, including offline fallbacks, image caching, and Google Fonts caching. It also offers “recipes” that can implement features with small, focused calls. Framework ecosystems can reduce effort further: Angular includes service worker support, and create-react-app can generate a service worker automatically. For learning and comparison, a Hacker News PWA showcase site provides examples across frameworks.

The build-from-scratch walkthrough narrows the project to four files: index.html, a logo, manifest.json, and serviceworker.js. The manifest references icon sizes used for home-screen installation, and an asset generator can create the required icon set automatically. In the service worker, Workbox routing matches image files and applies a caching strategy—cache-first for relatively static assets, with a network-then-cache approach for frequently changing content. After serving locally, developers verify icons, confirm the service worker is running, and run a Lighthouse audit to reach a near-perfect score and the installable badge.

Beyond the basics, the transcript points to additional resources like web.dev and Trusted Web Activities (TWAs) for publishing on Google Play alongside Android apps, plus Microsoft Store options for PWAs. It also teases an upcoming advanced browser-API video covering capabilities such as Bluetooth, motion, and idle detection.

Cornell Notes

PWAs turn mobile-friendly websites into installable apps that can work offline and use device capabilities, without maintaining separate native codebases. Lighthouse in Chrome DevTools is the main gatekeeper: it checks performance, accessibility, and whether the app meets installability requirements. Offline behavior typically comes from a service worker that caches URLs/assets and can handle background tasks like sync and push events. A manifest.json supplies install metadata (icons, name) and helps the browser recognize the app. Libraries like Workbox and framework tooling (Angular, create-react-app) reduce the amount of custom service-worker code needed, making a “from scratch” PWA achievable with a small set of files.

What makes a website qualify as a PWA, and how does Lighthouse help?

Chrome DevTools’ Lighthouse audit scores performance and accessibility and also determines whether the site is installable as a PWA. The baseline expectations include fast loading and mobile accessibility. The more difficult requirement is offline capability, which Lighthouse flags if the app can’t serve content without a network.

How does a service worker enable offline support?

A service worker is a background script registered by the browser that can intercept requests and serve cached responses. After registering serviceworker.js, developers cache the app’s URLs/assets so they can be viewed offline. DevTools’ Application tab helps confirm the service worker is active and lets developers inspect the cache and background services.

What role does manifest.json play in PWA installability?

manifest.json provides app metadata used for installation, including an icons array with multiple icon sizes for home-screen display. It also ties into install behavior by reflecting whether the service worker is up and running. Without correct manifest metadata, installation prompts and home-screen icons may not work as expected.

Why do developers often use Workbox instead of writing service-worker logic manually?

Workbox packages common service-worker patterns into reusable utilities, reducing custom code. It supports “recipes” that can add offline fallback, image caching, and Google Fonts caching quickly. It also includes routing and caching strategies (e.g., cache-first for static assets, network-then-cache for content that changes more often).

What are the minimal files needed to build a PWA from scratch in the walkthrough?

The build uses four files: index.html (main page), a logo, manifest.json (metadata and icons), and serviceworker.js (service worker registration and caching). index.html links to the manifest and registers the service worker when supported. The manifest’s icon set can be generated automatically using an asset generator (npx pwa asset generator).

How do developers verify the PWA works and meets requirements?

They check DevTools’ Application tab to confirm manifest icons appear and the service worker is running. Then they run a Lighthouse audit from the Lighthouse tab; a successful run yields a PWA installability badge (the walkthrough reports a 100 score across most metrics).

Review Questions

  1. What specific offline mechanism does a PWA rely on, and what does the service worker do when the network is unavailable?
  2. How do manifest.json and Lighthouse work together to determine whether an app is installable?
  3. Compare cache-first and network-then-cache strategies: when would each be the better fit?

Key Points

  1. 1

    PWAs deliver native-like mobile experiences (offline, push, device interactions) while keeping web distribution benefits and a single code base.

  2. 2

    Lighthouse in Chrome DevTools is the practical checklist for performance, accessibility, and installability requirements.

  3. 3

    Offline support usually depends on a service worker that caches URLs/assets and can handle background tasks.

  4. 4

    A manifest.json file supplies install metadata—especially correctly sized icons—and helps the browser recognize the app.

  5. 5

    Workbox and framework tooling (Angular service worker support, create-react-app) can implement common PWA features with minimal custom code.

  6. 6

    A “from scratch” PWA can be built with a small set of files: index.html, manifest.json, a serviceworker.js, and an icon set.

  7. 7

    PWAs can extend beyond browsers via Trusted Web Activities (TWAs) on Google Play and listing options in the Microsoft Store.

Highlights

A service worker is the linchpin for offline PWAs: it runs in the background and serves cached content when the network drops.
manifest.json isn’t just branding—its icons and metadata are essential for home-screen installation behavior.
Workbox “recipes” can add offline fallback and caching with very small code changes, making PWA implementation far less error-prone.
A minimal PWA build can reach Lighthouse installability scores by combining fast mobile loading, service-worker caching, and correct manifest metadata.

Topics

  • Progressive Web Apps
  • Service Workers
  • Manifest Files
  • Offline Caching
  • Workbox

Mentioned

  • PWA
  • CLI
  • SEO
  • TWAs