Skip to content

Instantly share code, notes, and snippets.

@nirzaq
Created March 8, 2018 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nirzaq/b91fdf3e468bc6c67d1ed1701a185f66 to your computer and use it in GitHub Desktop.
Save nirzaq/b91fdf3e468bc6c67d1ed1701a185f66 to your computer and use it in GitHub Desktop.
componentDidMount Next.js SWprecache
componentDidMount() {
if ("serviceWorker" in navigator) {
navigator.serviceWorker
.register("/service-worker.js")
.then(registration => {
console.log("service worker registration successful");
})
.catch(err => {
console.warn("service worker registration failed", err.message);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment