next.js
90450112 - [experiment] Add useOffline flag with offline retry behavior (#92011)

Commit
26 days ago
[experiment] Add useOffline flag with offline retry behavior (#92011) **Current:** 1. https://github.com/vercel/next.js/pull/92011 **Up next:** 2. https://github.com/vercel/next.js/pull/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`.
Author
Parents
Loading