Add a Service Worker
What is a service worker
A service worker is a script that your browser runs in the background, separate from a web page, opening the door to features that don’t need a web page or user interaction.They increase your site availability in spotty connections, and are essential to making a nice user experience.
It supports features like push notifications and background sync.
Using service workers in Gatsby with
Gatsby provides awesome plugin interface to create and load a service worker into your site gatsby-plugin-offline.
We recommend using this plugin together with the manifest plugin. (Don’t forget to list the offline plugin after the manifest plugin so that the manifest file can be included in the service worker).
npm install --save gatsby-plugin-offline
Add this plugin to your
// In your gatsby-config.js plugins: [`gatsby-plugin-offline`]