Book a free call

Building Progressive Web Apps With React: A Practical Guide

React plus a service worker turns a web app into an installable, offline-capable PWA. Here is the setup, the caching plan and the mistakes to avoid.

Hertiv engineering teamReviewed by a senior engineer
6 min read
Building Progressive Web Apps With React: A Practical Guide
On this page

Short answer

Building a progressive web app with React means taking a normal React web app and adding three things: a web manifest so it can be installed, a service worker so it works offline, and an app shell that loads fast on repeat visits. React handles the interface; the PWA parts handle installation and offline use.

What is a progressive web app built with React?

A progressive web app built with React is a React web app that behaves like an installed app: it can be added to a home screen, it opens in its own window, and it keeps working when the network drops. The React code renders the interface, while a manifest and a service worker supply the app-like behaviour.

The key point is that React and PWA are separate layers. React is the view library that builds the screens. The PWA parts are web platform features: the manifest describes the app, and the service worker is a script that sits between the app and the network, caching files and requests.

That separation is good news. You do not need a special React framework to build a PWA, and you do not rewrite your components. You add the PWA layer to the React app you already have, then test the offline and install behaviour the way a user would meet it.

What does React add to a PWA?

React adds the part PWAs are usually weakest at: a fast, stateful interface. Its component model and client-side routing fit the app-shell pattern, where the shell loads once and the content changes without full page reloads.

PWA featureWhat React providesWhat you still add
App shellComponents and routingCache-first service worker
InstallableNothing directlyWeb manifest, icons
Offline useState and local storageService worker caching
Fast repeat loadsCode splittingCache strategy per asset
Push updatesUI for the promptPush subscription logic

Code splitting deserves a note. React apps can grow large, and a PWA that caches everything on first visit will feel slow. Split routes into separate chunks and cache the shell first, then the routes the user actually visits.

How do you set up the project?

The simplest setup is Vite with the vite-plugin-pwa plugin, which generates the service worker and the manifest from a small configuration file. It wraps Workbox, the caching library, so you describe cache rules instead of writing service worker code by hand.

  1. Create the React app. Start a Vite React project, or use your existing one.
  2. Add the PWA plugin. Install vite-plugin-pwa and register it in the Vite configuration.
  3. Write the manifest. Name, short name, theme colour, display mode and icons, including a 512-pixel icon.
  4. Define cache rules. Cache the app shell first, then images and fonts, then API responses with a network-first rule.
  5. Build and serve over HTTPS. Service workers only run on secure origins, so test on HTTPS, even locally.
  6. Test the install prompt. Open the app in a mobile browser and check that the install option appears.

If your app already uses Create React App, the same ideas apply, but the tooling is older and the service worker template is minimal. Most new projects are better served by Vite. For the background on what a PWA is, what is a progressive web app explains the concept from the start.

How does the service worker cache your app?

The service worker intercepts network requests and decides, per request, whether to answer from the cache or go to the network. The choice is called a cache strategy, and picking the right one per asset type is the core skill of PWA building.

The app shell and static assets use cache-first: the service worker serves the cached copy immediately and updates it in the background. API data uses network-first: try the network, and fall back to the cached response when offline. Images often use stale-while-revalidate, which serves the cached copy fast and refreshes it quietly.

Versioning matters. When you ship a new build, the service worker must know the old cache is stale. The plugin handles this by hashing file names, but API responses you cache yourself need an expiry or a version key, or users will see old data long after the fix shipped.

How do you make the app installable?

An app becomes installable when it has a valid web manifest, is served over HTTPS, and has a service worker with a fetch handler. Browsers then offer an install prompt, and the user can add the app to a home screen or desktop.

The manifest is a small JSON file. It needs a name and short name, a start URL, a display mode of standalone or fullscreen, a theme colour, and icons at 192 and 512 pixels, including a maskable icon that fills the shape on Android. A missing 512-pixel icon is the most common reason the prompt never appears.

Do not force the prompt. Let the browser show it when the user has engaged with the app, or add your own install button that calls the deferred prompt at a sensible moment, such as after a task completes. Forcing installation on first visit annoys users and teaches them to dismiss it. For a plain-language introduction, introduction to progressive web apps covers the install flow.

How do you handle data when the user is offline?

Offline data handling is where most React PWAs fail, because caching the interface is easy and caching the data is not. The interface can load offline while the content is empty, which is worse than a clear offline message.

The practical pattern is to store the data the user needs in IndexedDB through a small library, and queue changes the user makes while offline. When the network returns, the queue syncs in order and conflicts are resolved by a rule you define, such as last write wins or server wins for shared records.

Keep the offline data set small. Cache the lists and records the user actually opens, not the whole database. A field-service app needs the day's jobs offline, not the full customer history. Show a clear offline indicator, so users know which data is fresh and which is cached.

Example (hypothetical): a field-service app that works offline

Example (hypothetical): a company builds a React PWA for 40 field technicians who visit customer sites. Each technician handles 25 jobs a day, and a third of the sites have no mobile signal.

Without offline support, a technician at a dead-zone site cannot open the job, so they call the office instead. That is 40 technicians times 8 dead-zone jobs, or 320 calls a day. With the PWA, the day's jobs are cached in the morning, the technician completes them offline, and the results sync when signal returns.

The arithmetic shows the gain: 320 calls a day at 3 minutes each is 960 minutes, or 16 hours of office time a day. Syncing offline results takes seconds per job and needs no phone call. The point is not the caching itself, but the work it removes from the office.

What are the common mistakes?

The most common mistakes in React PWAs are caching everything on first visit, forgetting the 512-pixel icon, and shipping an interface that loads offline with no data inside it.

  • Cache-all on first visit. Caching every route and image up front makes the first load slow. Cache the shell first.
  • Missing manifest icon. Without a 512-pixel icon, the install prompt never appears.
  • Testing only on desktop. Install and offline behaviour differ on mobile, so test on a real phone.
  • No cache expiry. API responses cached forever show stale data after a fix ships.
  • Offline interface, empty content. An app shell without cached data is a blank screen with a logo.
  • Skipping HTTPS. Service workers do not run on plain HTTP, so local testing must use a secure origin.

Key takeaways

  • React renders the interface; the manifest and service worker add the app behaviour
  • Cache the app shell first, then the routes users actually visit
  • Use network-first for API data and cache-first for static assets
  • Offline data needs IndexedDB and a sync queue, not just caching
  • A missing 512-pixel icon is the most common install failure

Frequently asked questions

Do I need a special framework to build a React PWA?

No. A normal React app plus a web manifest and a service worker is a PWA. The simplest path is Vite with the vite-plugin-pwa plugin, which generates the service worker and manifest from a small configuration file.

What is a service worker?

A service worker is a script that runs in the background of the browser and sits between your app and the network. It intercepts requests and decides whether to answer from the cache or fetch from the network, which is what makes offline use possible.

Can a React PWA work fully offline?

The interface can, and the data can if you plan for it. Cache the app shell with the service worker and store the records users need in IndexedDB, with a queue that syncs changes when the network returns. Without the data layer, the app loads but shows nothing.

How do I test a PWA during development?

Build the app and serve it over HTTPS, since service workers do not run on plain HTTP. Then use the browser developer tools to simulate offline mode, check the manifest in the application panel, and test installation on a real phone.

Does a PWA need an app store?

No. Users install a PWA from the browser, without an app store. That is one of its advantages, but it also means you handle distribution, updates and discovery yourself instead of relying on a store listing.

What is the app shell pattern?

The app shell is the minimal interface, header, navigation and layout, that loads once and stays cached. Content changes without full page reloads, which makes repeat visits fast. React's component model and client-side routing fit this pattern well.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: software products in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Planning a progressive web app and unsure where the offline layer starts? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Mobile App Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to contact@hertiv.com.

Prefer email? Write to contact@hertiv.com
Estimate costBook a call