shadowwalker / next-pwa

Zero config PWA plugin for Next.js, with workbox 🧰
MIT License
3.71k stars 312 forks source link

Next-PWA is not registering my service worker #506

Closed elVengador closed 3 months ago

elVengador commented 3 months ago

Summary

after install next-pwa and setup my next.config.js, Im running my aplication and there is not registered my service worker on my browser, I checked the path

Versions

How To Reproduce

I setup my next.config.js

/** @type {import('next').NextConfig} */
const nextConfig = {};

import nextPWA from 'next-pwa'
const withPWA = nextPWA({
    dest: 'public'
    register: true,
})
export default withPWA(nextConfig)

then run my application and check my browser

Expected Behaviors

my service worker should be registered automatically

Screenshots

there is no registered service worker:

image

but ther is the sw.js in the path:

image
elVengador commented 3 months ago

I solved adding a Script in my Layout file from NextJs to call sw.js and that register my service worker

hmh10098 commented 1 month ago

Can you give me an example script? I'm facing this issue too @elVengador