PWA NEW UPDATE AVAILABLE example.
create-react-app@3.4.0with@material-ui/core@^4.9.7@vue/cli@4.2.3withvuetify@^2.2.11
- Use
register-service-workerto listen onupdatedevent - When
updatedtriggered, declare a function topostMessagewith{ type: SKIP_WAITING }to the waiting worker, and it will make the workerskipWaiting(). - When the user click the REFRESH button, make the waiting worker
skipWaiting(),update()the registration andreload(). Now the latest app is loaded.
Choose a framework:
# React
cd react
# Vue
cd vueBuild the production and serve the app:
yarn buildNow open the browser and request http://localhost:5000/
Optional: You can stop the web server and reload the page. You would see that the PWA still works even it's offline.
Build the production and serve the app again:
yarn buildReload the page(not hard refresh) and you will see the update notification is pop-on as a snackbar. Click REFRESH and you'll see the body is changed.