lately, I have create two react application and in both of them the service worker is not present instead a new file is generated i.e ‘reportWebVitals.js’. Here is my folder structure of src after creating new app.
Also, if we check on running the app, the browser says that ‘No matching service worker detected’
Advertisement
Answer
Thanks @jonrsharpe So, CRA does not give support for service worker directly with default installation command as developer may not be making the application as PWA. So, they decided to keep it optional. Like me, if you anyone else want to install service worker while creating a new app, Prefer:
npx create-react-app my-app --template cra-template-pwa
instead of default npx create-react-app my-app
.
Hence, for more yo can refer to https://create-react-app.dev/docs/making-a-progressive-web-app/