How to detect if user goes offline

You need to listen for the window events online or offline.

function updateOnlineStatus(event) {
  // DO YOUR THING
}

window.addEventListener('online', updateOnlineStatus);
window.addEventListener('offline', updateOnlineStatus);

Copyright © 2024. Design and code by myself with Next.js. Fork it and create yours