silverwolf-x's picture
download
raw
1.75 kB
import { Suspense } from 'react'
import { headers } from 'next/headers'
import { getSentinelValue } from '../../../getSentinelValue'
export default async function Page() {
const pendingHeaders = headers()
return (
<section>
<h1>Deep Header Reader</h1>
<p>
This component was passed the headers promise returned by `headers()`.
It is rendered inside a Suspense boundary and it takes a second to
resolve so when rendering the page you should see the Suspense fallback
content before revealing the header value even though headers was called
at the page root.
</p>
<p>
If cacheComponents is turned off the `headers()` call would trigger a
dynamic point at the callsite and the suspense boundary would also be
blocked for over one second
</p>
<Suspense
fallback={
<>
<p>loading header data...</p>
<div id="fallback">{getSentinelValue()}</div>
</>
}
>
<DeepHeaderReader pendingHeaders={pendingHeaders} />
</Suspense>
</section>
)
}
async function DeepHeaderReader({
pendingHeaders,
}: {
pendingHeaders: ReturnType<typeof headers>
}) {
let output: Array<React.ReactNode> = []
for (const [name, value] of await pendingHeaders) {
if (name.startsWith('x-sentinel')) {
output.push(
<tr>
<td>{name}</td>
<td>{value}</td>
</tr>
)
}
}
await new Promise((r) => setTimeout(r, 1000))
return (
<>
<table>
<tr>
<th>Header Name</th>
<th>Header Value</th>
</tr>
{output}
</table>
<div id="page">{getSentinelValue()}</div>
</>
)
}

Xet Storage Details

Size:
1.75 kB
·
Xet hash:
9fa57fcf9a455f56d5acc5d30453c934f967f43b900029d61941506c81707bd2

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.