PWA and Create React App
We are going to create a progressive web app with CRA. the code will be at the end
To begin with let’s start a new cra.
$ npx create-react-app wb-example && cd wb-example

CRA on the newstest versions remove the serviceWorker.js, so let’s start with it

Copy the above code and paste it on yow serviceWorker.js. That code will let you register a service-worker on localhost.
Modified your index.js

// ADD THE IMPORT AT THE TOP
const config = {
/** @param {ServiceWorkerRegistration} registration */
onSuccess: (registration) => {
console.log("onSuccess", registration);
},
/** @param {ServiceWorkerRegistration} registration */
onUpdate: (registration) => {
console.log("onUpdate", registration);
}
}
register(config);
Now we have it as it used to be. it’s time to really work on what we came here
create a file call ./src/service-worker.js

build yow code
npm run build

now you can
$ serve -s build