@@ -83,7 +83,9 @@ A validation insight or error tells you a route won't render instantly. Resolve
...
@@ -83,7 +83,9 @@ A validation insight or error tells you a route won't render instantly. Resolve
export const instant = false
export const instant = false
```
```
> **Good to know**: `instant = false` marks a segment as _allowed to block_. It does not force the route to be dynamic, so a genuinely prerenderable route still ships a static shell. It also does not clear synchronous IO build errors: calls like `new Date()`, `Math.random()`, and `crypto.randomUUID()` still fail the prerender. See [Adopting incrementally](#adopting-incrementally).
Export `instant` from the segment'sServerComponentfile(`page`,`layout`,or`default`).Ifthatfilehasa`'use client'`directive,movetheclientcodeintoachildcomponentandkeeptheroutefileasaServerComponent.
@@ -142,7 +142,7 @@ The segment is always in the render tree, which means Next.js validates it on ev
...
@@ -142,7 +142,7 @@ The segment is always in the render tree, which means Next.js validates it on ev
## Skip validation on the segment
## Skip validation on the segment
Choose this fix when the segment is intentionally not rendered in certain states (a modal that only appears on interaction, a slot gated by authentication). Setting [`instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` on the dropped segment tells Next.js to skip validation for it.
Choose this fix when the segment is intentionally not rendered in certain states (a modal that only appears on interaction, a slot gated by authentication). Setting [`instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` on the dropped segment tells Next.js to skip this validation. It does not opt the segment out of prerendering or make it request-time rendered.
### Patterns
### Patterns
...
@@ -160,6 +160,29 @@ export default function ModalPage() {
...
@@ -160,6 +160,29 @@ export default function ModalPage() {
Route segment config must be exported from the segment'sServerComponentfile.IfthepageorlayoutiscurrentlyaClientComponent,moveitsclientcodeintoachildandkeeptheroutefileasaServerComponent:
```jsx filename="app/dashboard/@modal/page.js"
import { Modal } from './modal'
export const instant = false
export default function ModalPage() {
return <Modal />
}
```
```jsx filename="app/dashboard/@modal/modal.js"
'use client'
export function Modal() {
// Client state and browser APIs can stay here.
return <div>Modal</div>
}
```
### Trade-off
### Trade-off
Thesegmentisexemptfrominstant-navigationvalidation.Ifithasissuesthatwouldblocknavigation(uncacheddataoutsideSuspense,runtimeAPIs),thoseissueswon't be caught during development.
Thesegmentisexemptfrominstant-navigationvalidation.Ifithasissuesthatwouldblocknavigation(uncacheddataoutsideSuspense,runtimeAPIs),thoseissueswon't be caught during development.
...
@@ -167,7 +190,8 @@ The segment is exempt from instant-navigation validation. If it has issues that
...
@@ -167,7 +190,8 @@ The segment is exempt from instant-navigation validation. If it has issues that
### Gotchas
### Gotchas
- The export must be on the **dropped segment'sownfile**(pageorlayout),notonaparent.Theframeworkwalkstop-downandthefirstexplicitconfigwins.
- The export must be on the **dropped segment'sownfile**(pageorlayout),notonaparent.Theframeworkwalkstop-downandthefirstexplicitconfigwins.
- Setting [`instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` does not disable [prerendering](/docs/app/glossary#prerendering). The segment still prerenders if it can. It only disables the validation error.
-Theexportmustbeinthesegment's Server Component file. Do not add it to a file with the `'useclient'` directive.
- Setting [`instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` does not disable [prerendering](/docs/app/glossary#prerendering). The segment still prerenders if it can. It only disables the validation error. To defer work until an actual request, use [`connection()`](/docs/app/api-reference/functions/connection) in a component below a [`<Suspense>`](https://react.dev/reference/react/Suspense) boundary instead.