azizhk / workbox-route-bug

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Next.js + Workbox + Typescript Example

Steps to see the demo:

  1. Fork the Repo
  2. Register for Netlify
  3. Click on Create new Site from Git
  4. Choose your fork.
  5. In the Build Settings
    • Build Command: yarn build
    • Publish Directory: out
  6. Wait for Deploy to finish and then open your website in a tab.
  7. Now go to Netlify Deploys and trigger another deploy.
  8. Open your website in another tab. Both tabs should now have "New Version Available Toast"
  9. Click "Upgrade" on any one tab and then both tabs should reload.

This example covers:

  • Service Worker with Typescript
  • Service Worker Bundling (Provided by the workbox webpack plugin)
  • Precaching of client side assets when service worker starts
  • Communication to user that new update is available.
  • Reload all existing tabs when Service Worker is updated to avoid state mismatch.
  • Update service worker when user navigates (by clicking on link or some action)
  • Update service worker when user refreshes the page
  • How to use assetPrefix when assets are uploaded to CDN
  • Precache HTML assets in export mode.

Further Reading:

About


Languages

Language:TypeScript 85.5%Language:JavaScript 14.5%