diff --git a/gatsby-browser.js b/gatsby-browser.js index 476e6f8..066084a 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -22,3 +22,15 @@ wrapRootElement.propTypes = { // Layout with Page Transitions export const wrapPageElement = wrapPageElementWithLayout + +// 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() + } +}