Next-pwa: Background Sync API support?

Created on 3 Dec 2019  路  6Comments  路  Source: shadowwalker/next-pwa

Are there any easy approaches to have Background Sync API https://developers.google.com/web/tools/workbox/modules/workbox-background-sync so that handle API calls too?

enhancement

All 6 comments

I will investigate on that

@rrjanbiah Currently, there is no simple way to provide this feature in next-pwa.
But it's worth to try the trick:
Use next-pwa to generate a sw.js service worker file for you. Then set swSrc option in next.config.js to the sw.js file, so that next-pwa will call workbox to inject manifest to your custom service worker. In this case, you are using the generated sw.js file as a nice and clean baseline. You can add whatever code you want to the sw.js without worrying maintain the pre-cache manifest file change every time you build (since workbox inject it for you).

@shadowwalker Thank you so much for looking into it. Will try your suggestions little later and will update. Thanks again.

@rrjanbiah I added a custom worker example now: https://github.com/shadowwalker/next-pwa/tree/master/examples/custom-worker

This will help to add custom code to the service worker easily.

@shadowwalker Thank you so much for your help.

@rrjanbiah I added a custom worker example now: https://github.com/shadowwalker/next-pwa/tree/master/examples/custom-worker

This will help to add custom code to the service worker easily.

I clone your custom worker example and when I run it give me webpack not found error I install webpack and then I got this error "TypeError: Cannot read property 'tapPromise' of undefined"

I also check it on my own project but it did not work.

Was this page helpful?
0 / 5 - 0 ratings