Progressive Web App (PWA) integration with Drupal

Introduction to Progressive Web App (PWA)
Posted by Gulab Bisht

A Progressive Web App (PWA) is a web app that uses modern web capabilities to deliver an app-like experience to users by combining features offered by most modern browsers with the benefits of mobile experience. Integration of PWA with Drupal makes Drupal inherit the latest web technologies and harness devices capabilities. Before diving into integration with Drupal lets see what PWA is and how it affects today world of web.

Progressive Web App or PWA is like an alternative to native apps which has the following feature:

  • Progressive - Works for every user, regardless of browser choice because it's built with progressive enhancement as a core tenet.

  • Responsive - Fits any form factor: desktop, mobile, tablet, or whatever is next.

  • Connectivity independent - Enhanced with service workers to work offline or on low-quality networks.

  • App-like - Feels like an app, because the app shell model separates the application functionality from application content.

  • Fresh - Always up-to-date thanks to the service worker update process.

  • Safe - Served via HTTPS to prevent snooping and to ensure content hasn't been tampered with.

  • Discoverable - Is identifiable as an "application" thanks to W3C manifest and service worker registration scope, allowing search engines to find it.

  • Re-engageable - Makes re-engagement easy through features like push notifications.

  • Installable - Allows users to add apps they find most useful to their home screen without the hassle of an app store.

  • Linkable - Easily share the application via URL, does not require complex installation.

  • Low cost - PWA has a low development cost than the native app.

  • Rapid development - With low-cost PWA and easy and fast to develop as well then the native alternative of the app.

Why PWA?

According to the study native app losses 20% of users on every step that is needed to download and install the app. On the other hand, according to the stats, PWA showed better results in terms of conversion as PWA can be downloaded directly from the browser without going to any app store and it behaves as a normal app on your mobile.

PWA gets benefits from the web platform features to provides an app like experience. You can visit https://whatwebcando.today to identify your browser capabilities which can be used by any progressive web app.

Here is an example of features provided by Google Chrome (Version 65.0.3325.181).

What web can do today

Components of PWA

PWA contains 3 important parts:

  1. App shell: App shell provides minimal HTML, javascript and CSS that powers your application UI. It is loaded in less than a second. It is stored and served from the cache if available.

  2. Web manifest: This allows you to add your application to user’s home screen. It is added to the head tag of your page as below -

<link rel="manifest" href = "/manifest.json">

Manifest.json file defines all the components of how the progressive web app will behave.

PWA web manifest

  1. Service workers: Service Workers can be scripted to intercept every network request and serve a response from cache even when the user is offline.

Integration with Drupal

Progress Web App can be integrated with Drupal simply by using PWA module. This module out of the box makes the Drupal application PWA compatible without much of an effort.

Drupal 7 Integration

In Drupal 7 PWA module provide config form to generate the manifest.js file. And once a valid manifest.js file is generated, you can validate it with chrome’s lighthouse plugin.

Drupal 7 PWA integration
Drupal 7 configuration form

 

Drupal 7 PWA integration manifest output
Manifest.js output

Drupal 8 Integration

PWA integration in Drupal 8 is not as simple as enabling the module. Unlike Drupal 7 version of PWA module, Drupal 8 version doesn’t provide any configuration form to configure the manifest.js file and because of which even after enabling the module you won’t see any manifest.js file tag in the head.

One of the reason is the core issue to extend site information page to generate a manifest.js file. For is one issue is already logged in Drupal 8 version of PWA module to provide the config form functionality till the core issue is merged in the core.

So to make the PWA work on Drupal 8 sites first apply the patch provided in the issue. Once the patch is implemented goto admin/config/system/pwa and configure the settings.

Drupal 8 PWA integration
Drupal 8 configuration form after applying the patch

Some of the settings like the logo of the manifest.js file can be configured from the site logo setting on theme setting page.

Blockers & Requirements for PWA

Tools for PWA

Resources for PWA

PWA in action

  • Flipkart Lite

  • Zomato

  • Paytm Lite

  • Myntra

  • Jabong

PWA Case Study