How do I build a progressive web app?

Larry Foster
4 min readDec 10, 2021

The technology behind ‘progressive’ web applications came into being only a few years back and quickly gained momentum, paving the way ahead to building future-ready mobile applications.

Source: google

Progressive web applications are reliable, fast, and engaging. They bring out the best of mobile sites and native applications. Earlier, many brands overlooked the steady proliferation of mobile technology, yet it facilitates reaching out to their nascent customers.

Why Do Brands Invest in Progressive Web Apps?

PWA’s offer enhanced user experience through progressive enhancement. Robust PWA solutions help drive and accelerate technological capabilities, empowering companies, and adding the right balance to the business;

Progressive web apps work seamlessly in offline mode. They depict mobile-like behavior (native performance). PWA’s are highly performant and get installed smoothly. They do not require app store submission. It can — (1) send push notifications, (2) access the hardware of the mobile device, and (3) work in no network or unstable connections.

How to Build React Progressive Web App?

Catching up with the change, PWA’s have molded ‘along with’ existing architectures using libraries like React and JS module bundlers like webpack. As we hope to work around with minor tweaks, a PWA should not require a wholesale rewrite. Thrusting some metrics in place, shipping just what users need, routing, and throwing all non-essentials can be a good idea for fast performance.

Lighthouse is a tool for auditing, checking if the app meets a bar for web performance under emulated mobile conditions. It is available as a Chrome extension and Command Line Interface (CLI).

Which Top-Level Audits Should You Consider While Building React PWA?

  • If the network connection is secure;
  • It prompts users to add the app to the home screen;
  • To install the web app with a custom splash screen;
  • To load and install the app on offline/flaky connections;
  • To speed up the page performance;
  • To enhance the site progressively;
  • To design the site in a mobile-friendly manner;
  • To check if the address bar matches brand colors;

All these points are achievable with some caveats; Undeniably, web applications can be flaky. It has evolved from a document-centric platform to a first-class application platform.

Use JS libraries judiciously to make your application interactive.

Examples of Open-source React Progressive Web App

  • Universal rendering
  • Service worker app shell caching
  • Content caching in cache API
  • Built without React, React Router, and Firebase
  • Cross-browser, including UC browser
  • Optimized for Lighthouse

Top Examples of React PWA

  • Canva
  • Photoscape
  • Amazon
  • Flipkart
  • MI Store
  • In video

The Process to Build React Progressive Web App

Building React Progressive Web Application with React cross-platform app development framework, get the latest version of Node installed. Get yourself a code editor like Visual Studio Code. You have three options: (1) To lace a React app with ‘progressive’ functionalities, (2) Use Create React App tool by Facebook, (3) import ready-made React apps from Github.

  • To begin with, install Create React App tool in the system. Fire up your code editor, enter the following code: npm install –global create-react-app
  • The installation of the Create React App tool begins. Once it is complete, enter the following code: create — react — app react-PWA-example
  • # and cd in that directory
  • cd react — PWA — example
  • After the project, check the package.json file, notice the dependencies that come with the file. Install the ‘React — router’ dependency, using the code editor, and take a test by running the npm run start command.
  • You may use Lighthouse, which is a free extension by Google, to analyze a web app and show if it is progressive or not.
  • The example we explained above has a default service worker for ‘cache static’ assets, but we can create a custom service worker instead. For this, create a new service worker file in the source directory of your project, and replace the following code with the name of your custom service worker there: window.addEventListener(‘Load’, () => { const swUrl = ‘${process.env.PUBLIC_URL}/service-worker.js’;
  • Add a testing functionality to this service worker file by using the default console.log(“”) command.
  • Create a new production build of the app
  • Check the console. Lighthouse for an improved PWA score because of the added service worker functionality.
  • (Here, you can write more complex service worker code, depending on the ‘functionality you desire’)
  • Before the app initializes, display the loading messages or CSS by editing the index.html file to remove the import references of CSS files from app.js and index.js files and improve app performance. It helps in adding ‘secure contexts’ to enhance the ‘progressiveness’ of the app.
  • The create React App has a manifest file in the public directory. It helps in basic configurations. You may modify the public/manifest.json file to add functionalities like icons, install options, and PWA icons on the home screen or desktop for easy access.
  • After completing all the above steps, your app is ready for deployment. Use Firebase, turn on caching by changing the value of doCache to true. Install Firebase and initialize the Firebase module.
  • Once done, deploy by using the following code: npm run build && firebase deploy
  • The firebase CLI tool returns a URL, which opens in a web browser. The hosting URL will have HTTPS: https://pwa-example-1.firebaseapp.com
  • Execute the Lighthouse tool, and you will get 100 PWA SCORE. That implies that your PWA is ready.

Conclusive: Why Should You Create a React PWA?

When you are concerned with audience across platforms, the size and complexity of applications, the app performance, all the code that users need to download and install, then progressive web app become prominent. For all the good reasons discussed above, these are easy to create and deploy. They do not stare at the blank loading screen as the JavaScript initializes. Progressive web applications go well to build interactive user interfaces, combining ease of development with performance and capability, fast, beautiful, and functional web applications.

--

--