[experiment] Add useOffline hook to expose offline state to userland#92012
[experiment] Add useOffline hook to expose offline state to userland#92012acdlite merged 1 commit intovercel:canaryfrom
Conversation
Failing test suitesCommit: f19bfd6 | About building and testing Next.js
Expand output● Graceful Shutdown › production (standalone mode) › should not accept new requests during shutdown cleanup › should stop accepting new requests when shutting down
Expand output● interception-dynamic-segment › should work when interception route is paired with a dynamic segment ● interception-dynamic-segment › should intercept consistently with back/forward navigation ● interception-dynamic-segment › should intercept multiple times from root
Expand output● prefetch inlining › independent head: metadata is prefetched even when no runtime segment request is needed
Expand output● Telemetry CLI › production mode › cli session: custom babel config (preset) ● Telemetry CLI › production mode › cli session: next config with webpack ● Telemetry CLI › production mode › detect static 404 correctly for
Expand output● create-next-app --app (App Router) › should create project inside "src" directory with --src-dir flag
Expand output● proxy-missing-export › should NOT error when proxy file has a default function export ● proxy-missing-export › should NOT error when proxy file has a default arrow function export ● proxy-missing-export › should NOT error when proxy file has a named declaration function export ● proxy-missing-export › should NOT error when proxy file has a named declaration arrow function export ● proxy-missing-export › should error when proxy file has a named export with different name alias |
4dd2c6f to
888c806
Compare
4853774 to
c5be188
Compare
888c806 to
e5b9f41
Compare
c5be188 to
7a0a2e2
Compare
e5b9f41 to
a4f7ee2
Compare
7a0a2e2 to
4beaf4d
Compare
a4f7ee2 to
912c995
Compare
4beaf4d to
423131e
Compare
d55b571 to
1350499
Compare
**Current:** 1. #92011 **Up next:** 2. #92012 --- When a navigation, server action, or prefetch fails due to a network error, instead of falling back to MPA navigation or surfacing an error, the request blocks until connectivity is restored and then retries automatically. Offline detection works by treating any `fetch()` rejection as a network error (server errors resolve with a status code, they don't reject). Once offline, a polling loop does HEAD requests with exponential backoff to detect when connectivity returns. Browser offline/online events also feed into this loop. Successful fetches from other code paths can short-circuit the loop if they happen to land first. Follow-up work will add a `useOffline` hook so apps can show an offline indicator to the user, and allow navigations to read from stale cache entries while offline. Gated behind `experimental.useOffline`.
1350499 to
ed50f5c
Compare
Adds a useOffline() hook exported from next/navigation that returns true when the app is offline. The state is owned by a provider component rendered in the app router, using useState + useOptimistic so the value can update even during blocked transitions (e.g., a navigation that's waiting for connectivity). Gated behind the experimental.useOffline flag. Refresh of use-offline-hook
ed50f5c to
f19bfd6
Compare
Previous:
Current:
Adds a
useOffline()hook exported fromnext/navigationthat returnstruewhen the app is offline. The state is owned by a provider component rendered in the app router, usinguseState+useOptimisticso the value can update even during blocked transitions (e.g., a navigation that's waiting for connectivity).Gated behind
experimental.useOffline.