Skip to content

Latest commit

 

History

History

lifecycle

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

next-pwa - lifecycle and register workflow control example

[TOC]

This example demonstrates how to use the next-pwa plugin to turn a next.js based web application into a progressive web application (PWA) painlessly.

This example demonstrates how to control the service worker registration workflow (instead of automatically registering the service worker) and add an event listener to handle the lifecycle events. It gives you more control through the PWA lifecycle. The key here is to set the register option in next.config.js to false then call window.workbox.register() to register the service worker on your own.

UPDATE

This example also demonstrates how to prompt the user to reload the page when a new version is available.

Usage

Open in Gitpod

cd examples/lifecycle
yarn install
yarn build
yarn start

Recommended .gitignore

**/public/precache.*.js
**/public/sw.js