silverwolf-x's picture
download
raw
876 Bytes
import { headers } from 'next/headers'
import { connection } from 'next/server'
import { Suspense } from 'react'
export default async function Page() {
return (
<>
<p>
This page accesses headers synchronously at runtime. This triggers a
type error. In dev mode, we also log an explicit error that `headers()`
should be awaited.
</p>
<Suspense>
<HeadersReadingComponent />
</Suspense>
</>
)
}
async function HeadersReadingComponent() {
// Await a connection to test the subsequent sync headers access at runtime.
await connection()
// Cast to any as we removed UnsafeUnwrapped types, but still need to test with the sync access
const userAgent = (headers() as any).get('user-agent')
return (
<div>
this component reads the `user-agent` header synchronously: {userAgent}
</div>
)
}

Xet Storage Details

Size:
876 Bytes
·
Xet hash:
da87cc7bae309dc631556a7a1f1ef56b184af203a8676adf90bc6a7e00f71761

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