diff --git a/docs/modules/workbox.md b/docs/modules/workbox.md index 2b667296..451bb348 100644 --- a/docs/modules/workbox.md +++ b/docs/modules/workbox.md @@ -160,3 +160,28 @@ workbox: { ], } ``` + +### Hooking on service worker registration life cycle + +Create `plugins/sw.js`: + +```js +if ('serviceWorker' in navigator) { + navigator.serviceWorker.getRegistrations().then((registrations) => { + for (const worker of registrations) { + console.log('Service worker:', worker) + } + }); +} +``` + +Add it to the `plugins` section of `nuxt.config.js`: + +```js +{ + plugins: [ + src: '~/plugins/sw.js', + ssr: false + ] +} +```