DEV Community

Joodi
Joodi

Posted on

πŸš€ Next.js 16.3 Has a New useOffline Hook

Meet useOffline πŸ‘‡

It lets you know when the user loses their internet connection.

const isOffline = useOffline()

return isOffline
  ? <p>You’re offline</p>
  : <App />
Enter fullscreen mode Exit fullscreen mode

So instead of your app silently breaking when the connection drops, you can show a proper offline state.

For example:
πŸ“‘ Onlineβ†’ Show the app
πŸ“΄ Offlineβ†’ Show an offline message or disable actions that need the network


One important thing:

useOffline does not make your app offline-first.

You still need things like caching, IndexedDB, and sync logic if you want the app to actually work offline.

⚠️ useOffline is currently experimental, so its API may change.

πŸ“š Docs: Next.js Documentation

Top comments (0)