Ionic Progressive Web App

Because Ionic Apps are built with web technologies, they can run just as well as a Progressive Web App as they can a native app.

Not sure what PWAs are? Check out The Complete Guide To Progressive Web Apps with Ionic for more info.

Ionic 5 is a step forward for Progressive Web Apps, that's why we are building this new ionic template with 100% support for PWA.

You will be able to use this Ionic 5 starter as an iOS app, an Android app, a web app or as a PWA! Too many options, right?

For a web app to be considered a PWA, it needs to comply with 10 principles.

Making an Ionic App a PWA

The two main requirements of a PWA are a Service Worker and a Web Manifest. While it's possible to add both of these to an app manually, the Angular team has an @angular/pwa package that can be used to automate this.

The @angular/pwa package will automatically add a service worker and a app manifest to the app. To add this package to the app run:

$ ng add @angular/pwa

Once this package has been added run ionic build --prod and the www directory will be ready to deploy as a PWA.

Features like Service Workers and many JavaScript APIs (such as geolocation) require the app be hosted in a secure context. When deploying an app through a hosting service, be aware they HTTPS will be required to take full advantage of Service Workers.

After @angular/pwa has been added, a new ngsw-config.json file will be created at the root of the project. This file is responsible for configuring how Angular's service worker mechanism will handle caching assets.

You can learn more about how to customize this file in https://ionicframework.com/docs/angular/pwa#service-worker-configuration

How to install this template as a PWA on your phone?

For iOS

  • From the bottom slider, tap the "Add to Home Screen" option

  • Set the name you want

  • The app will now be available as a PWA from your home screen. Enjoy 😀

For Android

  • Click ADD.

  • The app will now be available as a PWA from your home screen. Enjoy 😀

Deploy to Firebase

One of the requirements of a PWA is that it needs to be served over https for enhanced security.

There are many hosting providers that offer HTTPS support, among them I find the Firebase Hosting product super easy to work with besides it’s free and provides many benefits for Progressive Web Apps.

Follow this detailed guide on how to Deploy Ionic apps using Firebase Hosting for more information.

Last updated