not-found.js
The not-found file is used to render UI when the notFound
function is thrown within a route segment. Along with serving a custom UI, Next.js will return a 200
HTTP status code for streamed responses, and 404
for non-streamed responses.
Good to know: In addition to catching expected
notFound()
errors, the rootapp/not-found.js
file also handles any unmatched URLs for your whole application. This means users that visit a URL that is not handled by your app will be shown the UI exported by theapp/not-found.js
file.
Props
not-found.js
components do not accept any props.
Data Fetching
By default, not-found
is a Server Component. You can mark it as async
to fetch and display data:
Version History
Version | Changes |
---|---|
v13.3.0 | Root app/not-found handles global unmatched URLs. |
v13.0.0 | not-found introduced. |