Unverified Commit 2ff53d5e authored by Aurora Scharff's avatar Aurora Scharff Committed by GitHub

docs: add Building guide (#94999)

Adds a **Building** guide (`docs/01-app/02-guides/building.mdx`): what
`next build` does, how to read the route table (`○` Static, `◐` Partial
Prerender, `ƒ` Dynamic), prerendering dynamic routes with
`generateStaticParams`, streaming request-time work, and debugging
prerender errors. Also links the guide from the deploying page and the
`next build` CLI reference.
parent 736ec443
...@@ -26,7 +26,7 @@ Next.js can be deployed to any provider that supports Node.js. Ensure your `pack ...@@ -26,7 +26,7 @@ Next.js can be deployed to any provider that supports Node.js. Ensure your `pack
} }
``` ```
Then, run `npm run build` to build your application and `npm run start` to start the Node.js server. This server supports all Next.js features. If needed, you can also eject to a [custom server](/docs/app/guides/custom-server). Then, run `npm run build` to [build your application](/docs/app/guides/building) and `npm run start` to start the Node.js server. This server supports all Next.js features. If needed, you can also eject to a [custom server](/docs/app/guides/custom-server).
Node.js deployments support all Next.js features. Learn how to [configure them](/docs/app/guides/self-hosting) for your infrastructure. Node.js deployments support all Next.js features. Learn how to [configure them](/docs/app/guides/self-hosting) for your infrastructure.
......
This diff is collapsed.
...@@ -188,6 +188,8 @@ The first visit to `/shoes/basketball-shoes`. Neither param was prerendered. Nex ...@@ -188,6 +188,8 @@ The first visit to `/shoes/basketball-shoes`. Neither param was prerendered. Nex
After the first visit, Next.js renders these routes in the background with the now-known params. The next visitor to the same URLs gets the upgraded result. After the first visit, Next.js renders these routes in the background with the now-known params. The next visitor to the same URLs gets the upgraded result.
> **Good to know**: The App Shell for unlisted params is served from Next.js 16.3. Earlier versions wait for a full server render before sending the response.
### What the upgrade produces ### What the upgrade produces
After the first visit, Next.js renders the page in the background with the known params and tries to push the static boundary as far down the component tree as possible: After the first visit, Next.js renders the page in the background with the known params and tries to push the static boundary as far down the component tree as possible:
...@@ -198,6 +200,12 @@ After the first visit, Next.js renders the page in the background with the known ...@@ -198,6 +200,12 @@ After the first visit, Next.js renders the page in the background with the known
> **Good to know**: Prefetching also triggers upgrades. When a [`<Link>`](/docs/app/api-reference/components/link) enters the viewport or [`router.prefetch`](/docs/app/api-reference/functions/use-router) is called, Next.js can upgrade the App Shell in the background, so the next visitor gets the more specific version even before anyone actually navigates to the page. > **Good to know**: Prefetching also triggers upgrades. When a [`<Link>`](/docs/app/api-reference/components/link) enters the viewport or [`router.prefetch`](/docs/app/api-reference/functions/use-router) is called, Next.js can upgrade the App Shell in the background, so the next visitor gets the more specific version even before anyone actually navigates to the page.
## Choosing what to prerender
Not every route needs to be prerendered. Every page you prerender increases build work and produces output that has to be stored and deployed. Many routes may never be visited before your next deployment, making that work unnecessary.
Instead, use [`generateStaticParams`](/docs/app/api-reference/functions/generate-static-params) to prerender the routes that benefit most from being ready ahead of time, such as popular pages or predictable content. Less frequently visited routes are generated on demand and upgraded after their first visit, so you don't spend build time and storage on pages that may never be requested.
## Coming from the Pages Router ## Coming from the Pages Router
If you are migrating from the Pages Router: If you are migrating from the Pages Router:
......
...@@ -89,6 +89,8 @@ Route (app) ...@@ -89,6 +89,8 @@ Route (app)
ƒ (Dynamic) server-rendered on demand ƒ (Dynamic) server-rendered on demand
``` ```
See the [Building guide](/docs/app/guides/building) to learn how to read the output, prerender dynamic routes, and debug build errors.
The following options are available for the `next build` command: The following options are available for the `next build` command:
| Option | Description | | Option | Description |
......
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