[TOC]
**Checkout this simple and easy way to implement offline fallbacks without inject manifest: **
This example demonstrates how to use next-pwa
to implement fallback route, image or font when fetch error. Fetch error usually happens when offline. (Note fetch is successful even when server returns error codes 404, 400, 500, ...
)
This example uses Inject Manifest module from workbox
. The advantage of using this module is you get more control over your service worker. The disadvantage is that it's more complicated and needs to write more code.
The idea of implementing comprehensive fallbacks can be found here.
In the future, using inject manifest may not be needed. When this proposal is completed in workbox v6.
cd examples/offline-fallback
yarn install
yarn build
yarn start
**/public/workbox-*.js
**/public/sw.js