Skip to content

Commit da0cbcc

Browse files
karlhorkyicyJoseph
andauthored
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: - #45801 (comment) 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: Joseph <sephxd1234@gmail.com> Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
1 parent dcf11d1 commit da0cbcc

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

docs/01-app/03-api-reference/03-file-conventions/not-found.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Next.js provides two conventions to handle not found cases:
1010

1111
## `not-found.js`
1212

13-
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.
13+
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).
1414

1515
```tsx filename="app/not-found.tsx" switcher
1616
import Link from 'next/link'

docs/01-app/03-api-reference/04-functions/not-found.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: notFound
33
description: API Reference for the notFound function.
44
---
55

6-
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.
6+
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.
77

88
## `notFound()`
99

0 commit comments

Comments
 (0)