Skip to content

Commit 121e1b5

Browse files
icyJosephmartinfrancoisliketigerMilancen123geraldochristiano
authored
[backport] docs: early October improvements and fixes (#84334)
Additional group of docs improvements. --------- Co-authored-by: François Martin <f.martin@fastmail.com> Co-authored-by: liketiger <50165633+liketiger@users.noreply.github.com> Co-authored-by: Milancen123 <122306536+Milancen123@users.noreply.github.com> Co-authored-by: geraldochristiano <68152918+geraldochristiano@users.noreply.github.com> Co-authored-by: JJ Kasper <jj@jjsweb.site> Co-authored-by: Anshuman Bhardwaj <anshu5074@gmail.com> Co-authored-by: Karl Horky <karl.horky@gmail.com> Co-authored-by: João Henrique <117238473+joao4xz@users.noreply.github.com> Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
1 parent 1b276c9 commit 121e1b5

File tree

16 files changed

+156
-46
lines changed

16 files changed

+156
-46
lines changed

docs/01-app/01-getting-started/01-installation.mdx

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,52 @@ description: Learn how to create a new Next.js application with the `create-next
55

66
{/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
77

8+
<AppOnly>
9+
10+
Create a new Next.js app and run it locally.
11+
12+
## Quick start
13+
14+
1. Create a new Next.js app named `my-app`
15+
2. `cd my-app` and start the dev server.
16+
3. Visit `http://localhost:3000`.
17+
18+
```bash package="pnpm"
19+
pnpm create next-app@latest my-app --yes
20+
cd my-app
21+
pnpm dev
22+
```
23+
24+
```bash package="npm"
25+
npx create-next-app@latest my-app --yes
26+
cd my-app
27+
npm run dev
28+
```
29+
30+
```bash package="yarn"
31+
yarn create next-app@latest my-app --yes
32+
cd my-app
33+
yarn dev
34+
```
35+
36+
```bash package="bun"
37+
bun create next-app@latest my-app --yes
38+
cd my-app
39+
bun dev
40+
```
41+
42+
- `--yes` skips prompts using saved preferences or defaults. The default setup enables TypeScript, Tailwind, App Router, and Turbopack, with import alias `@/*`.
43+
44+
</AppOnly>
45+
846
## System requirements
947

1048
Before you begin, make sure your system meets the following requirements:
1149

1250
- [Node.js 18.18](https://nodejs.org/) or later.
1351
- macOS, Windows (including WSL), or Linux.
1452

15-
## Automatic installation
53+
## Create with the CLI
1654

1755
The quickest way to create a new Next.js app is using [`create-next-app`](/docs/app/api-reference/cli/create-next-app), which sets up everything automatically for you. To create a project, run:
1856

docs/01-app/01-getting-started/02-project-structure.mdx

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ Top-level files are used to configure your application, manage dependencies, run
5252

5353
### Routing Files
5454

55+
Add `page` to expose a route, `layout` for shared UI such as header, nav, or footer, `loading` for skeletons, `error` for error boundaries and `route` for APIs.
56+
5557
| | | |
5658
| ----------------------------------------------------------------------------- | ------------------- | ---------------------------- |
5759
| [`layout`](/docs/app/api-reference/file-conventions/layout) | `.js` `.jsx` `.tsx` | Layout |
@@ -66,35 +68,50 @@ Top-level files are used to configure your application, manage dependencies, run
6668

6769
### Nested routes
6870

69-
| | |
70-
| --------------- | -------------------- |
71-
| `folder` | Route segment |
72-
| `folder/folder` | Nested route segment |
71+
Folders define URL segments. Nesting folders nests segments. Layouts at any level wrap their child segments. A route becomes public when a `page` or `route` file exists.
72+
73+
| Path | URL pattern | Notes |
74+
| --------------------------- | --------------- | ----------------------------- |
75+
| `app/layout.tsx` || Root layout wraps all routes |
76+
| `app/blog/layout.tsx` || Wraps `/blog` and descendants |
77+
| `app/page.tsx` | `/` | Public route |
78+
| `app/blog/page.tsx` | `/blog` | Public route |
79+
| `app/blog/authors/page.tsx` | `/blog/authors` | Public route |
7380

7481
### Dynamic routes
7582

76-
| | |
77-
| ------------------------------------------------------------------------------------------------------ | -------------------------------- |
78-
| [`[folder]`](/docs/app/api-reference/file-conventions/dynamic-routes#convention) | Dynamic route segment |
79-
| [`[...folder]`](/docs/app/api-reference/file-conventions/dynamic-routes#catch-all-segments) | Catch-all route segment |
80-
| [`[[...folder]]`](/docs/app/api-reference/file-conventions/dynamic-routes#optional-catch-all-segments) | Optional catch-all route segment |
83+
Parameterize segments with square brackets. Use `[segment]` for a single param, `[...segment]` for catch‑all, and `[[...segment]]` for optional catch‑all. Access values via the [`params`](/docs/app/api-reference/file-conventions/page#params-optional) prop.
84+
85+
| Path | URL pattern |
86+
| ------------------------------- | -------------------------------------------------------------------- |
87+
| `app/blog/[slug]/page.tsx` | `/blog/my-first-post` |
88+
| `app/shop/[...slug]/page.tsx` | `/shop/clothing`, `/shop/clothing/shirts` |
89+
| `app/docs/[[...slug]]/page.tsx` | `/docs`, `/docs/layouts-and-pages`, `/docs/api-reference/use-router` |
8190

8291
### Route Groups and private folders
8392

84-
| | |
85-
| ------------------------------------------------------------------------------ | ------------------------------------------------ |
86-
| [`(folder)`](/docs/app/api-reference/file-conventions/route-groups#convention) | Group routes without affecting routing |
87-
| [`_folder`](#private-folders) | Opt folder and all child segments out of routing |
93+
Organize code without changing URLs with route groups [`(group)`](/docs/app/api-reference/file-conventions/route-groups#convention), and colocate non-routable files with private folders [`_folder`](#private-folders).
94+
95+
| Path | URL pattern | Notes |
96+
| ------------------------------- | ----------- | ----------------------------------------- |
97+
| `app/(marketing)/page.tsx` | `/` | Group omitted from URL |
98+
| `app/(shop)/cart/page.tsx` | `/cart` | Share layouts within `(shop)` |
99+
| `app/blog/_components/Post.tsx` || Not routable; safe place for UI utilities |
100+
| `app/blog/_lib/data.ts` || Not routable; safe place for utils |
88101

89102
### Parallel and Intercepted Routes
90103

91-
| | |
92-
| ------------------------------------------------------------------------------------------- | -------------------------- |
93-
| [`@folder`](/docs/app/api-reference/file-conventions/parallel-routes#slots) | Named slot |
94-
| [`(.)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept same level |
95-
| [`(..)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept one level above |
96-
| [`(..)(..)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept two levels above |
97-
| [`(...)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept from root |
104+
These features fit specific UI patterns, such as slot-based layouts or modal routing.
105+
106+
Use `@slot` for named slots rendered by a parent layout. Use intercept patterns to render another route inside the current layout without changing the URL, for example, to show a details view as a modal over a list.
107+
108+
| Pattern (docs) | Meaning | Typical use case |
109+
| ------------------------------------------------------------------------------------------- | -------------------- | ------------------------------------ |
110+
| [`@folder`](/docs/app/api-reference/file-conventions/parallel-routes#slots) | Named slot | Sidebar + main content |
111+
| [`(.)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept same level | Preview sibling route in a modal |
112+
| [`(..)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept parent | Open parent child as overlay |
113+
| [`(..)(..)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept two levels | Deeply nested overlay |
114+
| [`(...)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept from root | Show arbitrary route in current view |
98115

99116
### Metadata file conventions
100117

docs/01-app/01-getting-started/14-metadata-and-og-images.mdx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ related:
1313
- app/api-reference/file-conventions/metadata/opengraph-image
1414
- app/api-reference/file-conventions/metadata/robots
1515
- app/api-reference/file-conventions/metadata/sitemap
16+
- app/api-reference/config/next-config-js/htmlLimitedBots
1617
---
1718

1819
The Metadata APIs can be used to define your application metadata for improved SEO and web shareability and include:
@@ -117,9 +118,15 @@ export default function Page({ params, searchParams }) {}
117118

118119
### Streaming metadata
119120

120-
For dynamically rendered pages, if resolving `generateMetadata` might block rendering, Next.js streams the resolved metadata separately and injects it into the HTML as soon as it's ready.
121+
For dynamically rendered pages, Next.js streams metadata separately, injecting it into the HTML once `generateMetadata` resolves, without blocking UI rendering.
121122

122-
Statically rendered pages don’t use this behavior since metadata is resolved at build time.
123+
Streaming metadata improves perceived performance by allowing visual content to stream first.
124+
125+
Streaming metadata is **disabled for bots and crawlers** that expect metadata to be in the `<head>` tag (e.g. `Twitterbot`, `Slackbot`, `Bingbot`). These are detected by using the User Agent header from the incoming request.
126+
127+
You can customize or **disable** streaming metadata completely, with the [`htmlLimitedBots`](/docs/app/api-reference/config/next-config-js/htmlLimitedBots#disabling) option in your Next.js config file.
128+
129+
Statically rendered pages don’t use streaming since metadata is resolved at build time.
123130

124131
Learn more about [streaming metadata](/docs/app/api-reference/functions/generate-metadata#streaming-metadata).
125132

docs/01-app/02-guides/backend-for-frontend.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ To implement this pattern, use:
2828

2929
- [Route Handlers](/docs/app/api-reference/file-conventions/route)
3030
- [`middleware`](/docs/app/api-reference/file-conventions/middleware)
31-
- In Pages Router, [API Routes](/pages/building-your-application/routing/api-routes)
31+
- In Pages Router, [API Routes](/docs/pages/building-your-application/routing/api-routes)
3232

3333
## Public Endpoints
3434

docs/01-app/02-guides/forms.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default function Page() {
5050
}
5151
```
5252

53-
> **Good to know:** When working with forms that have multiple fields, you can use the [`entries()`](https://developer.mozilla.org/en-US/docs/Web/API/FormData/entries) method with JavaScript's [`Object.fromEntries()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries). For example: `const rawFormData = Object.fromEntries(formData)`.
53+
> **Good to know:** When working with forms that have multiple fields, use JavaScript's [`Object.fromEntries()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries). For example: `const rawFormData = Object.fromEntries(formData)`. Note that this object will contain extra properties prefixed with `$ACTION_`.
5454
5555
## Passing additional arguments
5656

docs/01-app/02-guides/json-ld.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ nav_title: JSON-LD
44
description: Learn how to add JSON-LD to your Next.js application to describe your content to search engines and AI.
55
---
66

7-
[JSON-LD](https://json-ld.org/) is a format for structured data that can be used by search engines and AI to to help them understand the structure of the page beyond pure content. For example, you can use it to describe a person, an event, an organization, a movie, a book, a recipe, and many other types of entities.
7+
[JSON-LD](https://json-ld.org/) is a format for structured data that can be used by search engines and AI to help them understand the structure of the page beyond pure content. For example, you can use it to describe a person, an event, an organization, a movie, a book, a recipe, and many other types of entities.
88

99
Our current recommendation for JSON-LD is to render structured data as a `<script>` tag in your `layout.js` or `page.js` components.
1010

docs/01-app/02-guides/lazy-loading.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ By default, Server Components are automatically [code split](https://developer.m
2424
## Examples
2525

2626
<AppOnly>
27+
2728
### Importing Client Components
2829

2930
```jsx filename="app/page.js"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export class GracefullyDegradingErrorBoundary extends Component<
219219
ErrorBoundaryProps,
220220
ErrorBoundaryState
221221
> {
222-
private contentRef: React.RefObject<HTMLDivElement>
222+
private contentRef: React.RefObject<HTMLDivElement | null>
223223

224224
constructor(props: ErrorBoundaryProps) {
225225
super(props)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function onRequestError(
8888
request: {
8989
path: string // resource path, e.g. /blog?name=foo
9090
method: string // request method. e.g. GET, POST, etc
91-
headers: { [key: string]: string }
91+
headers: { [key: string]: string | string[] }
9292
},
9393
context: {
9494
routerKind: 'Pages Router' | 'App Router' // the router type

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export default function Layout(props: LayoutProps<'/dashboard'>) {
105105
> **Good to know**:
106106
>
107107
> - Types are generated during `next dev`, `next build` or `next typegen`.
108+
> - After type generation, the `LayoutProps` helper is globally available. It doesn't need to be imported.
108109
109110
### Root Layout
110111

0 commit comments

Comments
 (0)