Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Enrique Pablo Molinari

Rating No ratings yet

In this book we are going to implement a Progressive Web App (PWA) using a step-by-step approach. This learning experience starts with an already crafted React application called Task List, created using the create-react-app tool with the cra-template-pwa template, which gives us a good starting point for building a progressive web app. We will go into the details about how to make the web app installable and after that how to improve the user experience by adding offline support to the web app. To make the learning process smooth I will first add offline support for the read-only use cases of the application. After that, I will show how to provide full offline support by using the IndexedDB database and the Background Sync service. I will also explain how to update progressive web apps. How users get notified that there is a new release of the application waiting to be installed and how that actually happens. About the Author Enrique Molinari holds a Master in Software Engineering at Universidad Nacional de La Plata (Argentina). With 20 years of experience in the software industry he has worked in many software projects as developer, technical lead and architect. He is also professor at Universidad Nacional de Río Negro, in charge of the Object Oriented Design and Advanced Database Systems undergraduate courses.

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A hands-on guide that takes a working React app and turns it into a fully installable, offline-capable Progressive Web App, one feature at a time. Best for React developers who want a practical, code-along path to native-like web experiences rather than a theory-heavy PWA overview. 【Book Arc】 - **Opening (~0%–10%)**: Frames what "progressive" means and why PWAs sit between plain websites and native apps, then sets up the development environment (VS Code, snippets, Prettier) and the sample Task List app. - **Early (~10%–30%)**: Gets the starter project running behind a reverse proxy (Kong/Nginx) or LocalTunnel, then introduces the Service Worker as the engine behind PWA capabilities and walks through registration and the install/activate lifecycle. - **Middle (~30%–50%)**: Explains caching with Workbox — precaching, runtime routes, cache storage — and shows how to inspect the service worker and caches in Chrome DevTools. - **Late (~50%–75%)**: Makes the app installable via the web app manifest (name, icons, start_url, display, theme/background colors) and begins adding offline support, starting with read-only use cases. - **Ending (~75%–100%)**: Extends to full offline support using IndexedDB and Background Sync, then covers app updates — how users are notified of a new release and how the new service worker takes over. (Excerpts do not cover the final update mechanics in detail.) 【Key Takeaways】 - **A PWA is a web app that borrows native-app capabilities** (Opening): installability, splash screens, offline support, background sync, and push notifications — all enabled by modern browser features rather than a separate codebase. - **The Service Worker is the foundation of everything PWA** (Early): it's a background-thread JavaScript program that intercepts network requests, and it's what makes offline behavior possible at all. - **Registration is a required, explicit step** (Early): the `cra-template-pwa` template ships with `service-worker.js` and `serviceWorkerRegistration.js`, but registration is disabled by default — you must switch `unregister()` to `register()`. - **The service worker lifecycle governs behavior** (Early–Middle): install, activate, and message events drive caching and updates; understanding this cycle is essential before debugging offline issues. - **Workbox handles the caching heavy lifting** (Middle): Google's module set provides precaching, routing, and strategies like StaleWhileRevalidate, plus expiration plugins to cap cache size. - **Installability depends on a well-formed manifest** (Late): name/short_name, 192×192 and 512×512 icons, start_url, display mode, and theme/background colors determine how the app appears once installed. - **Offline support can be layered incrementally** (Late): the book deliberately starts with read-only offline cases before tackling full offline, making the learning curve manageable. - **Full offline needs IndexedDB plus Background Sync** (Ending): writes are stored locally and synced to the server once connectivity returns, closing the gap between read-only and true offline use. 【Reading Tips】 - Deep-read the Service Worker lifecycle and Workbox chapters — they're the conceptual core; skim the environment setup and proxy/LocalTunnel configuration if you already have a working dev stack. - Keep Chrome DevTools open on the Application tab throughout; the book relies on inspecting Service Workers and Cache Storage to verify each step. - Treat the Task List app as a lab: after each feature (installable, read-only offline, full offline), break it deliberately (go offline, clear caches) to see how it behaves. - Don't skip the manifest details — small mistakes in icons or display mode are the most common reason an app won't install. - If you're new to IndexedDB, budget extra time for the full-offline section; it's the steepest part of the book. 【Coverage Limits】 This guide is based on stratified excerpts covering roughly the first half of the book in detail; the IndexedDB, Background Sync, and app-update chapters are summarized from the introduction and are not deeply represented in the source material.
Page 3
ogressive Web Apps? . . . . . . . . . . . . . . . . . . 8 1.3 Capabilities of Progressive Web Apps . . . . . . . . . . . . . . 8 2 Crafting your First PWA 10...
View in text
Page 14
u will see the Task List front-end. 2.1.2 Using LocalTunnel If you don’t want to go with a reverse proxy, the alternative I will propose is to use localtunne...
View in text
Excerpt 3
ation.js source code. CHAPTER 2. CRAFTING YOUR FIRST PWA 24 might trigger in a different thread the download of your static files in order to cache them. Thi...
View in text
Excerpt 4
images too. CHAPTER 2. CRAFTING YOUR FIRST PWA 34 Figure 2.9: Chrome DevTools - Service Worker Figure 2.10: Chrome DevTools - Cached content CHAPTER 2. CRAFT...
View in text
Excerpt 5
Figure 2.16: Chrome DevTools - latest-tasks cache populated We have improved how the application manages the retrieval of the task list under connectivity is...
View in text
Excerpt 6
tarter project, since we use it to inform the user when the internet connection has gone. The first change we will do is to move the render of the OfflineAle...
View in text
Excerpt 7
e worker listening to and processing sync events, obtaining the data from IndexedDB and sending it to the remote service. Figure 4.1: Using Background Sync a...
View in text
Excerpt 8
succeeds we register the Background Sync event. The service worker will then proceed with the replication if there is connectivit
View in text
Tags
AI categories
Web TechnologyJavaScriptSoftware
Publisher: Leanpub
Publish Year: 2022
Language: English
Pages: 98
File Format: PDF
File Size: 2.3 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…