Files
1dda5b668b [Breaking] Remove deprecated sync access to Dynamic APIs (#84179)
This PR removes the deprecated sync access to Dynamic APIs.

- Removed UnsafeUnwrapped* types.
- Replaced `as unknown as UnsafeUnwrapped ` type casts to `as any` for
dev warning.
- Removed tests that expected sync access to not error.
- Removed `UntrackedExotic` functions.
- Modified tests that were accidentally doing sync access.
- Updated warnings to emphasize that it is a Promise and must be
awaited.
- Removed paragraph that states access is allowed from
`errors/sync-dynamic-apis.mdx`.

---------

Co-authored-by: Josh Story <[email protected]>
2025-09-27 22:44:45 +02:00

40 lines
976 B
React

import React from 'react'
import * as next from 'next/headers'
export const Dynamic = async ({ pathname, fallback = null, params = null }) => {
if (fallback) {
return <div data-fallback>Dynamic Loading...</div>
}
const headers = await next.headers()
const messages = []
for (const name of ['x-test-input', 'user-agent']) {
messages.push({ name, value: headers.get(name) })
}
return (
<dl>
{pathname && (
<>
<dt>Pathname</dt>
<dd data-pathname={pathname}>{pathname}</dd>
</>
)}
{messages.map(({ name, value }) => (
<React.Fragment key={name}>
<dt>
Header: <code>{name}</code>
</dt>
<dd>{value ?? `MISSING:${name.toUpperCase()}`}</dd>
</React.Fragment>
))}
{params && (
<>
<dt>Params</dt>
<dd data-params={JSON.stringify(params)}>{JSON.stringify(params)}</dd>
</>
)}
</dl>
)
}