19 Sapper offline support

 

This chapter covers

  • Progressive web applications (PWAs)
  • Service worker overview
  • Caching strategies used by service workers
  • Sapper service worker configuration
  • Service worker events
  • Managing service workers in Chrome
  • Enabling the use of HTTPS in the Sapper server
  • Verifying offline behavior

Progressive web applications (PWAs) are apps created using browser-supported technologies such as HTML, CSS, and JavaScript. They can run on any platform with a standard web browser, including desktop computers, tablets, and phones. Their primary features are the ability to run when offline, receive push notifications, and interact with device features such as cameras.

Note

When an app attempts to use device features, users are typically prompted to give permission to the app. For example, an app that uses the camera to identify a food item or diagnose a skin condition would be required to ask for permission to use the camera.

Users must be online the first time they browse a PWA so the files that implement it can be downloaded to the browser. After downloading a PWA, it can optionally be installed. This typically adds an icon to the home screen and allows it to be invoked by tapping or double-clicking an icon instead of explicitly browsing the app URL. It also makes the PWA appear more like a native application because it can run without displaying browser chrome (such as a browser menubar and tabs).

19.1 Service worker overview

19.2 Caching strategies

19.3 Sapper service worker configuration

19.4 Service worker events

19.5 Managing service workers in Chrome

19.6 Enabling the use of HTTPS in the Sapper server

19.7 Verifying offline behavior

19.8  Building the Travel Packing app

Summary