I have developed a next app in the nx monopo and I need convert it to pwa app. I try to install next-pwa package but I dont know how should I change the next config file.
I dont think there is any difference between using a monorepo or multirepo for Next.js. You just need to update the next.config.js
as desired.
Once the next-pwa
package is installed, open your next.config.js
file and update it as follows (source):
const withNx = require("@nrwl/next/plugins/withNx");
const withPWA = require("next-pwa");
module.exports = withNx(
withPWA({
pwa: {
dest: "public",
register: true,
skipWaiting: true,
},
// Other Next.js configuration options
})
);
This configuration sets the destination directory for the PWA files to the public folder, enables the service worker registration, and skips waiting for the service worker to activate.