Skip to content

Not getting service worker with create-react-app

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. File Structure

Also, if we check on running the app, the browser says that ‘No matching service worker detected’

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. enter image description here Hence, for more yo can refer to https://create-react-app.dev/docs/making-a-progressive-web-app/