question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PWA not working in production

See original GitHub issue

What version of Next.js are you using?

12.0.1

What version of Node.js are you using?

14.17.4

What browser are you using?

Chrome

What operating system are you using?

Windows

How are you deploying your application?

Vercel

Describe the Bug

I implemented PWA using next-pwa in my application, and went through all the necessary steps. ( creating service worker, next-config file, etc ). Everything looks fine in development - “Install app” option pops up . But in production it just seems to disappear, and not even shows the install option

Expected Behavior

PWA pop-up should both appear in development as well as in production.

To Reproduce

  • Install next-pwa
  • Generate manifest ( using Simicart ).
  • Creating _document.js and adding the necessary links.
import Document, { Html, Head, Main, NextScript } from "next/document";

class MyDocument extends Document {
  render() {
    return (
      <Html>
        <Head>
          <link rel="manifest" href="/manifest.json" />
          <link rel="apple-touch-icon" href="/icon.png"></link>
          <meta name="theme-color" content="#fff" />
        </Head>
        <body>
          <Main />
          <NextScript />
        </body>
      </Html>
    );
  }
}

export default MyDocument;
  • Configure next-config file
const withPWA = require("next-pwa");

module.exports = withPWA({
  pwa: {
    dest: "public",
    register: true,
    skipWaiting: true,
  },
});
  • Add following to .gitginore
# PWA files
**/public/sw.js
**/public/workbox-*.js
**/public/worker-*.js
**/public/sw.js.map
**/public/workbox-*.js.map
**/public/worker-*.js.map

Also followed according to Nextjs pwa example

For more details visit this repo

Screenshots from Chrome dev tools - image

Production link - https://adaalat.vercel.app

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:22 (3 by maintainers)

github_iconTop GitHub Comments

11reactions
hulliscommented, Nov 9, 2021

Working on this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next-Pwa not working on production server such as Nginx
It is working on the development on local dev server but when I deploy to production like DigitalOcean with nginx it's not working...
Read more >
How to build and deploy a PWA with Next.js - Bird Eats Bug
This command builds the application for production usage. npm run build. Next we run npm run start to start our Next.js app in...
Read more >
How To Deploy a PWA Demo Server in Production Mode
This article describes how to deploy an Intershop Progressive Web Application (PWA) for a demo server in production mode.
Read more >
How to Build a Progressive Web App (PWA) with React
js , you should be able to see it running in the Application tab. Inside that tab, on the left side you should...
Read more >
next-pwa - npm
js . Though next-pwa automatically generate the worker box development build during development (by running next ) and worker box production ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found