React JS – registerServiceWorker() with create-react-app

When you use create-react-app to initiate a React JS project, you would get a line in index.js that will look like this:


I was asked a few times do you need it and for what. Technically, this is a decision by the creators of the create-react-app package to facilitate faster loading for offline or returning users. If you expect that people with low bandwidth will be visiting your app often, it is a good idea to keep it for now. They are good performance enhancers for offline use as well. But, as one of the developers tweeted,”They are an amazing technology but the pitfalls today are too significant to be a good default.”

I usually remove the line for web apps and I do not get any complaints.

Have in mind that the next version of create-react-app is supposed to have the service workers off by default. You would be able to switch them on when needed.