The repo is open source
// next.config.js
const withPWA = require("next-pwa");
module.exports = withPWA({
pwa: {
dest: "public",
sw: '/sw.js'
},
});
I have checked weather the PWA is working on the above URL or not using
function isPwa() {
return ["fullscreen", "standalone", "minimal-ui"].some(
(displayMode) => window.matchMedia('(display-mode: ' + displayMode + ')').matches
);
}
isPwa() // false
// https://stackoverflow.com/questions/41742390/javascript-to-check-if-pwa-or-mobile-web
You may want to use the next-pwa
package like this:
const withPWA = require("next-pwa");
const runtimeCaching = require("next-pwa/cache");
module.exports = withPWA({
pwa: {
dest: "public",
runtimeCaching,
disable: process.env.NODE_ENV === "development",
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.