Added docs on async `not-found.js` server components (#51999)
While `not-found.js` components do not accept any props, you can still turn the `not-found.js` component into an async server component to fetch dynamic data:
```tsx filename="app/blog/not-found.tsx" switcher
import Link from 'next/link'
import { headers } from "next/headers";
export default async function NotFound() {
const headersList = headers();
const domain = headersList.get("host")
const data = await getSiteData(domain)
return (
<div>
<h2>Not Found: {data.name}</h2>
<p>Could not find requested resource</p>
<p>
View <Link href="/blog">all posts</Link>
</p>
</div>
)
}
```
Co-authored-by:
Lee Robinson <9113740+leerob@users.noreply.github.com>
Co-authored-by:
JJ Kasper <22380829+ijjk@users.noreply.github.com>
Showing
Please
register
or
sign in
to comment