Ashwani Panwar
Ashwani Panwar

Reputation: 4608

Unable to create Nextjs PWA setup

I am creating a setup for Next.js PWA but its not wokring. I have tried with

  1. Created manifest.json and other icons inside public folder.

  2. Created _document.js inside src/pages with below text

    import Document, { Html, Head, Main, NextScript, } from 'next/document'

    class MyDocument extends Document { render() { return ( ) } }

    export default MyDocument

  3. Updated next.config file with

         const withPWA = require('next-pwa')({
       dest: 'public',
       register: true,
       skipWaiting: true,
       disable: process.env.NODE_ENV === 'development'
     })
     /** @type {import('next').NextConfig} */
     const nextConfig = {
       reactStrictMode: true
     }
    
     module.exports = withPWA(nextConfig)
    
  4. Created fresh build but still browser not showing download icon. Note sure what is missed ?

Upvotes: 1

Views: 140

Answers (1)

Ashwani Panwar
Ashwani Panwar

Reputation: 4608

Issue was in selecting src folder. Working file location /pages/_document.js but if we put pages folder inside src fodler like /src/pages/_document.js then it does not works.

Upvotes: 0

Related Questions