Making a very simple PWA with NextJS shouldn't require installing a package.
PWABuilder Studio is not required, but helps a lot.
- Create a manifest.json file in the public directory.
- Create a service-worker.js file in the public directory.
- Update
app/layout.js
to specify manifest and a themeColor in viewport.
At this point the service worker is available, but not being used.
- Create a script file that will register the service worker at
public/sw-register.js
- Invoke this script in the root layout file using
Script
fromnext/script
- Cache the html and assets on service worker install.
- When online, respond to fetch requests with the placeholder offline page .
Video: Building offline-first Progressive Web Apps - Google I/O 2016
Old (NextJS 13) blog about PWA but useful