mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
**Previous:** 1. https://github.com/vercel/next.js/pull/92011 **Current:** 2. (this PR) --- 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 `experimental.useOffline`.
26 lines
607 B
TypeScript
26 lines
607 B
TypeScript
import { Suspense } from 'react'
|
|
import { connection } from 'next/server'
|
|
import { OfflineStatus } from '../../components/offline-status'
|
|
|
|
async function DynamicContent() {
|
|
await connection()
|
|
return <div id="destination-dynamic">Dynamic data loaded</div>
|
|
}
|
|
|
|
export default function DestinationPage() {
|
|
return (
|
|
<div id="destination-content">
|
|
<h1>Destination page</h1>
|
|
<Suspense
|
|
fallback={
|
|
<div id="destination-loading">
|
|
Waiting for data... <OfflineStatus />
|
|
</div>
|
|
}
|
|
>
|
|
<DynamicContent />
|
|
</Suspense>
|
|
</div>
|
|
)
|
|
}
|