Unverified Commit da0cbcce authored by Karl Horky's avatar Karl Horky Committed by GitHub

Add not-found.js / notFound() links to Status Codes section (#88332)

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

Add links to the helpful [Status Codes section of the `loading.js` docs
page](https://nextjs.org/docs/app/api-reference/file-conventions/loading#status-codes)
from the
[`not-found.js`](https://nextjs.org/docs/app/api-reference/file-conventions/not-found)
and
[`notFound()`](https://nextjs.org/docs/app/api-reference/functions/not-found)
docs pages

### Why?

To avoid misunderstandings that the streamed HTTP 200 responses are
negatively affecting SEO, as posited in such articles:

-
https://matthewmorek.com/journal/how-to-fix-next-js-notfound-returning-200-ok-with-app-router-and-suspense

It is mentioned in the `loading.js` docs as well as @ztanner's comment
here:

- https://github.com/vercel/next.js/issues/45801#issuecomment-2104816811

But not yet on the `not-found.js` or `notFound()` docs pages:

<img width="1439" height="629" alt="Screenshot 2026-01-09 at 17 16 24"
src="https://github.com/user-attachments/assets/5a2c9edf-1c28-4ae5-ab6e-08ac5ea703f7"
/>
<img width="1440" height="538" alt="Screenshot 2026-01-09 at 17 16 41"
src="https://github.com/user-attachments/assets/e83d3dbd-b175-4375-8aa2-311744d2daf2"
/>


### How?

Add some small edits

### Alternatives considered

1. Duplicating the Status Codes content to the `not-found.js` and
`notFound()` pages so it's accessible in all 3 places
   1. Copying and pasting the whole section
2. Making it a "partial" or "include" which can be used in both places
2. Moving the "Status Codes" (and maybe "SEO") section(s) out of the
`loading.js` page into a separate docs page

But both of those options require a bit more work and thinking.

---------
Co-authored-by: 's avatarJoseph <sephxd1234@gmail.com>
Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
parent dcf11d11
......@@ -10,7 +10,7 @@ Next.js provides two conventions to handle not found cases:
## `not-found.js`
The **not-found** file is used to render UI when the [`notFound`](/docs/app/api-reference/functions/not-found) 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.
The **not-found** file is used to render UI when the [`notFound`](/docs/app/api-reference/functions/not-found) 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 (see [Status Codes](/docs/app/api-reference/file-conventions/loading#status-codes) for details about SEO).
```tsx filename="app/not-found.tsx" switcher
import Link from 'next/link'
......
......@@ -3,7 +3,7 @@ title: notFound
description: API Reference for the notFound function.
---
The `notFound` function allows you to render the [`not-found file`](/docs/app/api-reference/file-conventions/not-found) within a route segment as well as inject a `<meta name="robots" content="noindex" />` tag.
The `notFound` function allows you to render the [`not-found file`](/docs/app/api-reference/file-conventions/not-found) within a route segment as well as inject a [`<meta name="robots" content="noindex" />`](/docs/app/api-reference/file-conventions/loading#status-codes) tag for search engines.
## `notFound()`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment