Skip to content
This repository was archived by the owner on Nov 19, 2023. It is now read-only.
This repository was archived by the owner on Nov 19, 2023. It is now read-only.

Offline indication #26

@satelllte

Description

@satelllte

Offline detection can be implemented using:

  useEffect(() => {
    // TODO: notify user that the app is available for offline use
    // ...

    // https://developer.chrome.com/docs/workbox/modules/workbox-window/#register-a-service-worker-and-notify-the-user-the-very-first-time-that-service-worker-is-active
    // @ts-ignore
    const wb = window.workbox
    // @ts-ignore
    wb.addEventListener('activated', (event) => {
      if (!event.isUpdate) {
        console.info('WB | activated | event: ', event)
        
        // READY FOR OFFLINE USE   !!!!!!
        // do something with it ....
      }
    })
  }, [])

Workbox docs reference: https://developer.chrome.com/docs/workbox/modules/workbox-window/#register-a-service-worker-and-notify-the-user-the-very-first-time-that-service-worker-is-active

To turn off page reload after getting back online, reloadOnOnline: false can be set in next-pwa config: https://github.com/shadowwalker/next-pwa#available-options

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions