Progressive Web App with Angular 14

Updated : 04/07/22 danny

What are we going to do?

We will turn our Standard Web Application into a PWA (Progressive Web App)
We will use the Angular version 14.0.4 javascript framework.

This is Step 8 of our  Angular guide which will allow us to obtain a PWA Web Application.
We will use an existing project whose characteristics are

  • Generated with Angular CLI
  • Routing
  • Lazy Loading
  • Framework CSS Bootstrap
  • Server Side Rendering
  • HttpClient
  • Transfer State

All created sources are indicated at the end of the tutorial.

The application is at the following address

Before you start

2008 App Store is an application store distributed by Apple on mobile devices running iOS.
2012 Google Play Store is an online application store created by Google.

2014, the global annual sales of smartphones exceed one billion units.

2017 two operating systems for mobile is sharing the global smartphone market.
Android 85.1 %  and IOS 14.8%

More than 50% of Internet searches are now done on mobile in France.

Android and iOS operating systems are written in different programming languages.
IOS applications work on Objective-C / Swift, while Android applications run on Java.

If you want to develop a mobile application, you can either develop a specific version for each platform or use a cross platform tool that will allow you to have only one source for both OS.
It will still manage registration on the app store.
In all cases users must go to a download platform to install an app.

In 2015, Frances Berriman and Google engineer Alex Russell propose the term "progressive web apps"

A PWA looks like a regular website, from a secure URL but allows a user experience similar to that of a mobile application, without the constraints of the latter (submission to App Stores, significant use of the device memory


We will use the Angular documentation to apply this technique.

We will use the command angular-cli
ng add

# Ajout de la librairie pwa
ng add @angular/pwa --project angular-starter

Angular-cli automatically made a number of changes to our project.

  • modify the package.json file (in this example we will update dependencies and descriptors)
  • edit angular.json file
  • creating the ngsw-config.json file
  • creating the src/manifest.webmanifest file
  • edit src/index.html file
  • edit src/app.browser.module.ts file
  • icons creationsrc/app/assets/icons
  "dependencies": {
    "@angular/animations": "13.1.1",
    "@angular/common": "13.1.1",
    "@angular/compiler": "13.1.1",
    "@angular/core": "13.1.1",
    "@angular/forms": "13.1.1",
    "@angular/platform-browser": "13.1.1",
    "@angular/platform-browser-dynamic": "13.1.1",
    "@angular/platform-server": "13.1.1",
    "@angular/router": "13.1.1",
    "@angular/service-worker": "13.1.1",
    "@fortawesome/fontawesome-free": "5.15.4",
    "@nguniversal/express-engine": "13.0.1",
    "bootstrap": "5.1.3",
    "express": "4.17.2",
    "rxjs": "7.4.0",
    "tslib": "2.3.1",
    "zone.js": "0.11.4"
  "devDependencies": {
    "@angular-devkit/build-angular": "13.1.2",
    "@angular/cli": "13.1.2",
    "@angular/compiler-cli": "13.1.1",
    "@nguniversal/builders": "13.0.1",
    "@types/express": "4.17.13",
    "@types/jasmine": "3.10.2",
    "@types/node": "17.0.0",
    "jasmine-core": "3.10.1",
    "karma": "6.3.9",
    "karma-chrome-launcher": "3.1.0",
    "karma-coverage": "2.1.0",
    "karma-jasmine": "4.0.1",
    "karma-jasmine-html-reporter": "1.7.0",
    "typescript": "4.5.4"

"assets": [


        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/angular-starter/browser",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "",
            "assets": [
            "styles": [
            "scripts": [
            "serviceWorker": true,
            "ngswConfigPath": "ngsw-config.json"
  "$schema": "./node_modules/@angular/service-worker/config/schema.json",
  "index": "/index.html",
  "assetGroups": [
      "name": "app",
      "installMode": "prefetch",
      "resources": {
        "files": [
      "name": "assets",
      "installMode": "lazy",
      "updateMode": "prefetch",
      "resources": {
        "files": [
  "name": "angular-starter",
  "short_name": "angular-starter",
  "theme_color": "#1976d2",
  "background_color": "#fafafa",
  "display": "standalone",
  "scope": "/",
  "start_url": "/",
  "icons": [
      "src": "assets/icons/icon-72x72.png",
      "sizes": "72x72",
      "type": "image/png"
      "src": "assets/icons/icon-96x96.png",
      "sizes": "96x96",
      "type": "image/png"
      "src": "assets/icons/icon-128x128.png",
      "sizes": "128x128",
      "type": "image/png"
      "src": "assets/icons/icon-144x144.png",
      "sizes": "144x144",
      "type": "image/png"
      "src": "assets/icons/icon-152x152.png",
      "sizes": "152x152",
      "type": "image/png"
      "src": "assets/icons/icon-192x192.png",
      "sizes": "192x192",
      "type": "image/png"
      "src": "assets/icons/icon-384x384.png",
      "sizes": "384x384",
      "type": "image/png"
      "src": "assets/icons/icon-512x512.png",
      "sizes": "512x512",
      "type": "image/png"
<!doctype html>
<html lang="en">
  <meta charset="utf-8">
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">

  <!-- Global site tag (gtag.js) - Google Analytics -->
  <script async="" src=""></script>
    window.dataLayer = window.dataLayer || [];
    function gtag() { dataLayer.push(arguments); }
    gtag('js', new Date());

    gtag('config', 'YOUR-ID');

  <link rel="manifest" href="manifest.webmanifest">
  <meta name="theme-color" content="#1976d2">
  <noscript>Please enable JavaScript to continue using this application.</noscript>
import { NgModule } from '@angular/core';
import { BrowserModule, BrowserTransferStateModule } from '@angular/platform-browser';

import { AppModule } from './app.module';
import { AppComponent } from './app.component';
import { ServiceWorkerModule } from '@angular/service-worker';
import { environment } from '../environments/environment';

  imports: [
    BrowserModule.withServerTransition({ appId: 'angular-starter' }),
    ServiceWorkerModule.register('ngsw-worker.js', {
      enabled: environment.production,
      // Register the ServiceWorker as soon as the app is stable
      // or after 30 seconds (whichever comes first).
      registrationStrategy: 'registerWhenStable:30000'
  bootstrap: [AppComponent],
export class AppBrowserModule { }


Nous allons tester le fonctionnement de la PWA

The npm run start script executes the ng serve command
ng serve does not work with service workers

To test, you must use an http server.

Les scripts suivants pemettent donc de tester notre pwa

  • npm run build:ssr
  • npm run serve:ssr
  • http://localhost:4000/


All you have to do is open Chrome development tools with Ctrl + Maj + J
And run a test of the Lighthouse tool

  • Audits
  • Run audits