diff --git a/gatsby-browser.js b/gatsby-browser.js index c40415d9..e5f987bb 100755 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -5,3 +5,15 @@ import './src/styles/global.scss' if (typeof window.IntersectionObserver === 'undefined') { import('intersection-observer') } + +// Display a message when a service worker updates +// https://www.gatsbyjs.org/docs/add-offline-support-with-a-service-worker/#displaying-a-message-when-a-service-worker-updates +export const onServiceWorkerUpdateReady = () => { + const answer = window.confirm( + 'This application has been updated. ' + + 'Reload to display the latest version?' + ) + if (answer === true) { + window.location.reload() + } +}