Unverified Commit 5b99d26d authored by Aurora Scharff's avatar Aurora Scharff Committed by GitHub

instant: polish client-hook overlay wording, cards, and docs links (#94496)

### What?

Polishes the dev-overlay UX for the client-hook prerender error after
Josh's framework fix landed in
[#94494](https://github.com/vercel/next.js/pull/94494). The overlay now
names the hook in the headline and shows per-hook fix cards.

### Why?

Different hooks need different fixes. `useSearchParams` always suspends,
but `generateStaticParams` doesn't apply to it. `useParams` is the only
hook GSP resolves at build time. `usePathname` and
`useSelectedLayoutSegment(s)` need a Suspense boundary or the `[block]`
export.

### How?

- Headline now reads "Next.js encountered URL data `useX()` in a Client
Component outside of `<Suspense>`", matching the body factory wording.
- Per-hook card sets in `instant-guidance-data.ts`: `useSearchParams` →
Stream + Block; `useParams` → Stream + GSP + Block; `usePathname` /
`useSelectedLayoutSegment(s)` → Stream + Block.
- Build-time message in `ClientHookDynamicError` /
`ParamClientHookDynamicError` matches the overlay card set.
- Companion docs page:
[vercel/front#72622](https://github.com/vercel/front/pull/72622).

### Verification

Demo scenarios on the [error-messages-overhaul test
app](https://error-messages-overhaul-ibsl.labs.vercel.dev/):
[88-client-use-pathname](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/88-client-use-pathname),
[89-client-use-search-params](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/89-client-use-search-params),
[90-client-use-params](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/90-client-use-params),
[91-client-use-selected-layout-segment](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/91-client-use-selected-layout-segment),
[92-client-use-selected-layout-segments](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/92-client-use-selected-layout-segments).

<!-- NEXT_JS_LLM_PR -->

---------
Co-authored-by: 's avatarJosh Story <gnoff@storyposted.com>
parent 6f4d94ac
......@@ -67,6 +67,7 @@ To learn more about these options, see the [MDN docs](https://developer.mozilla.
- `cookies` is an **asynchronous** function that returns a promise. You must use `async/await` or React's [`use`](https://react.dev/reference/react/use) function to access cookies.
- In version 14 and earlier, `cookies` was a synchronous function. To help with backwards compatibility, you can still access it synchronously in Next.js 15, but this behavior will be deprecated in the future.
- `cookies` is a [Request-time API](/docs/app/glossary#request-time-apis) whose returned values cannot be known ahead of time. Using it in a layout or page will opt a route into [dynamic rendering](/docs/app/glossary#dynamic-rendering).
- With [Cache Components](/docs/app/api-reference/config/next-config-js/cacheComponents), calling `cookies()` outside of a [`<Suspense>`](https://react.dev/reference/react/Suspense) boundary prevents the route from being prerendered. See [Next.js encountered runtime data during prerendering](/docs/messages/blocking-prerender-runtime) for fix options.
- The `.delete` method can only be called:
- In a [Server Function](/docs/app/getting-started/mutating-data) or [Route Handler](/docs/app/api-reference/file-conventions/route).
- If it belongs to the same domain from which `.set` is called. For wildcard domains, the specific subdomain must be an exact match. Additionally, the code must be executed on the same protocol (HTTP or HTTPS) as the cookie you want to delete.
......
......@@ -1313,6 +1313,8 @@ export default function Page() {
The `DynamicMarker` component renders nothing but tells Next.js the page has intentional dynamic content. By wrapping it in Suspense, the static content still prerenders normally.
See [Next.js encountered runtime data in `generateMetadata()`](/docs/messages/blocking-prerender-metadata-runtime) and [Next.js encountered uncached data in `generateMetadata()`](/docs/messages/blocking-prerender-metadata-dynamic) for full fix options and trade-offs.
### Ordering
Metadata is evaluated in order, starting from the root segment down to the segment closest to the final `page.js` segment. For example:
......
......@@ -192,7 +192,7 @@ export async function generateViewport() {
}
```
If viewport genuinely requires runtime data, wrap the document `<body>` in a Suspense boundary to signal that the entire route should be dynamic:
If viewport genuinely requires runtime data, wrap the document `<body>` in a [`<Suspense>`](https://react.dev/reference/react/Suspense) boundary to signal that the entire route should be dynamic. The shell ships immediately and the document streams in once the viewport resolves:
```tsx filename="app/layout.tsx" highlight={1,13,17}
import { Suspense } from 'react'
......@@ -216,7 +216,26 @@ export default function RootLayout({ children }) {
}
```
Caching is preferred because it allows static shell generation. Wrapping the document `body` in Suspense means there is no static shell or content to immediately send when a request arrives, making the entire route block until ready on every request.
Alternatively, opt the segment out of instant-navigation validation with [`unstable_instant = false`](/docs/app/api-reference/file-conventions/route-segment-config/instant). The route renders on every request and the navigation blocks until the render completes:
```tsx filename="app/dashboard/layout.tsx" highlight={1,3}
import { cookies } from 'next/headers'
export const unstable_instant = false
export async function generateViewport() {
const cookieJar = await cookies()
return {
themeColor: cookieJar.get('theme-color')?.value,
}
}
export default function DashboardLayout({ children }) {
return <section>{children}</section>
}
```
Setting `unstable_instant = false` opts only the segment that exports it out. Descendant segments are still validated by the global default. See [Next.js encountered runtime data in `generateViewport()`](/docs/messages/blocking-prerender-viewport-runtime) for the full set of fix options, trade-offs, and the subtree-wide opt-out.
> **Good to know**: Use [multiple root layouts](/docs/app/api-reference/file-conventions/layout#root-layout) to isolate fully dynamic viewport to specific routes, while still letting other routes in your application generate a static shell.
......
......@@ -46,6 +46,7 @@ export default async function Page() {
- In version 14 and earlier, `headers` was a synchronous function. To help with backwards compatibility, you can still access it synchronously in Next.js 15, but this behavior will be deprecated in the future.
- Since `headers` is read-only, you cannot `set` or `delete` the outgoing request headers.
- `headers` is a [Request-time API](/docs/app/glossary#request-time-apis) whose returned values cannot be known ahead of time. Using it in will opt a route into **[dynamic rendering](/docs/app/glossary#dynamic-rendering)**.
- With [Cache Components](/docs/app/api-reference/config/next-config-js/cacheComponents), calling `headers()` outside of a [`<Suspense>`](https://react.dev/reference/react/Suspense) boundary prevents the route from being prerendered. See [Next.js encountered runtime data during prerendering](/docs/messages/blocking-prerender-runtime) for fix options.
## Examples
......
......@@ -66,6 +66,17 @@ For example:
| `app/shop/[tag]/[item]/page.js` | `/shop/1/2` | `{ tag: '1', item: '2' }` |
| `app/shop/[...slug]/page.js` | `/shop/1/2` | `{ slug: ['1', '2'] }` |
## Behavior
### Cache Components
When [`cacheComponents`](/docs/app/api-reference/config/next-config-js/cacheComponents) is enabled, `useParams` may require a [`Suspense`](https://react.dev/reference/react/Suspense) boundary. This depends on whether the params can be resolved during prerendering.
- **Static routes and routes with [`generateStaticParams`](/docs/app/api-reference/functions/generate-static-params)**: every dynamic param is known at build time. `useParams` resolves on the server and no `Suspense` boundary is required.
- **Routes with dynamic params not covered by `generateStaticParams`**: the param is not known until request time. `useParams` suspends. Wrap the component (or a parent) in a `Suspense` boundary so its fallback can be rendered during prerendering; otherwise, the build fails.
See [Next.js encountered URL data in a Client Component outside of Suspense](/docs/messages/blocking-prerender-client-hook) for full fix options and trade-offs.
## Version History
| Version | Changes |
......
......@@ -76,6 +76,8 @@ When [`cacheComponents`](/docs/app/api-reference/config/next-config-js/cacheComp
This applies even when the component that calls `usePathname` is itself static. For example, a sidebar with active links rendered in a layout suspends on any page below it that has an unknown dynamic param. To keep the rest of the layout prerendered, wrap the component that calls `usePathname` (or a parent) in a `Suspense` boundary with a fallback.
See [Next.js encountered URL data in a Client Component outside of Suspense](/docs/messages/blocking-prerender-client-hook) for full fix options and trade-offs.
## Examples
### Do something in response to a route change
......
......@@ -85,6 +85,8 @@ This allows a part of the route to be prerendered while the dynamic part that us
We recommend wrapping the Client Component that uses `useSearchParams` in a `<Suspense/>` boundary. This will allow any Client Components above it to be prerendered and sent as part of initial HTML. [Example](/docs/app/api-reference/functions/use-search-params#prerendering).
See [Next.js encountered URL data in a Client Component outside of Suspense](/docs/messages/blocking-prerender-client-hook) for full fix options and trade-offs.
For example:
```tsx filename="app/dashboard/search-bar.tsx" switcher
......
......@@ -77,6 +77,8 @@ When [`cacheComponents`](/docs/app/api-reference/config/next-config-js/cacheComp
This applies even when the component that calls `useSelectedLayoutSegment` is itself static. For example, a tab bar rendered in a parent layout suspends on any page below it that has an unknown dynamic param. To keep the rest of the layout prerendered, wrap the component that calls `useSelectedLayoutSegment` (or a parent) in a `Suspense` boundary with a fallback.
See [Next.js encountered URL data in a Client Component outside of Suspense](/docs/messages/blocking-prerender-client-hook) for full fix options and trade-offs.
## Examples
### Creating an active link component
......
......@@ -89,6 +89,8 @@ When [`cacheComponents`](/docs/app/api-reference/config/next-config-js/cacheComp
This applies even when the component that calls `useSelectedLayoutSegments` is itself static. For example, a breadcrumb component rendered in a parent layout suspends on any page below it that has an unknown dynamic param. To keep the rest of the layout prerendered, wrap the component that calls `useSelectedLayoutSegments` (or a parent) in a `Suspense` boundary with a fallback.
See [Next.js encountered URL data in a Client Component outside of Suspense](/docs/messages/blocking-prerender-client-hook) for full fix options and trade-offs.
## Version History
| Version | Changes |
......
......@@ -271,7 +271,7 @@ Navigations to this route are not instant. The user waits for the full server re
### Gotchas
- Setting [`unstable_instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` on a layout exempts every route in the subtree, not only the layout itself. Audit child routes before opting a shared layout out.
- Setting [`unstable_instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` opts only the segment that exports it out. Descendant segments are still validated by the global default. See [Don't want this validation?](#dont-want-this-validation) for the subtree-wide opt-out.
- This export does not disable [prerendering](/docs/app/glossary#prerendering). The route still prerenders if it can. It only silences the instant-navigation validation error.
## Don't want this validation?
......
......@@ -297,7 +297,7 @@ Navigations to this route are not instant. The user waits for the full server re
### Gotchas
- Setting [`unstable_instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` on a layout exempts every route in the subtree, not only the layout itself. Audit child routes before opting a shared layout out.
- Setting [`unstable_instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` opts only the segment that exports it out. Descendant segments are still validated by the global default. See [Don't want this validation?](#dont-want-this-validation) for the subtree-wide opt-out.
- This export does not disable [prerendering](/docs/app/glossary#prerendering). The route still prerenders if it can. It only silences the instant-navigation validation error.
## Don't want this validation?
......
......@@ -283,7 +283,7 @@ Navigations to this route are not instant. The user waits for the full server re
### Gotchas
- Setting [`unstable_instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` on a layout exempts every route in the subtree, not only the layout itself. Audit child routes before opting a shared layout out.
- Setting [`unstable_instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` opts only the segment that exports it out. Descendant segments are still validated by the global default. See [Don't want this validation?](#dont-want-this-validation) for the subtree-wide opt-out.
- This export does not disable [prerendering](/docs/app/glossary#prerendering). The route still prerenders if it can. It only silences the instant-navigation validation error.
## Don't want this validation?
......
......@@ -112,7 +112,7 @@ Navigations to this route are not instant. The user waits for the full server re
### Gotchas
- Setting [`unstable_instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` on a layout exempts every route in the subtree, not only the layout itself. Audit child routes before opting a shared layout out.
- Setting [`unstable_instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` opts only the segment that exports it out. Descendant segments are still validated by the global default. See [Don't want this validation?](#dont-want-this-validation) for the subtree-wide opt-out.
- This export does not disable [prerendering](/docs/app/glossary#prerendering). The route still prerenders if it can. It only silences the instant-navigation validation error.
- Framework-synthesized routes (`/_not-found`, `/_global-error`) inherit the root layout's `generateViewport` and must be statically prerendered. [`unstable_instant = false`](/docs/app/api-reference/file-conventions/route-segment-config/instant) silences the validation error but does not let those routes through, so the build still fails when they prerender. If your root layout's `generateViewport` depends on request data, [Cache the viewport data](#cache-the-viewport-data) instead, or move to [`global-not-found.js`](/docs/app/api-reference/file-conventions/not-found#global-not-foundjs-experimental), which bypasses the root layout entirely and avoids inheriting its `generateViewport`.
......
......@@ -112,7 +112,7 @@ Navigations to this route are not instant. The user waits for the full server re
### Gotchas
- Setting [`unstable_instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` on a layout exempts every route in the subtree, not only the layout itself. Audit child routes before opting a shared layout out.
- Setting [`unstable_instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` opts only the segment that exports it out. Descendant segments are still validated by the global default. See [Don't want this validation?](#dont-want-this-validation) for the subtree-wide opt-out.
- This export does not disable [prerendering](/docs/app/glossary#prerendering). The route still prerenders if it can. It only silences the instant-navigation validation error.
- If the dynamic viewport is the only reason the route blocks, consider whether a static default covers most users. A static `themeColor` with a client-side correction after hydration may give a better experience than blocking the entire navigation.
- Framework-synthesized routes (`/_not-found`, `/_global-error`) inherit the root layout's `generateViewport` and must be statically prerendered. [`unstable_instant = false`](/docs/app/api-reference/file-conventions/route-segment-config/instant) silences the validation error but does not let those routes through, so the build still fails when they prerender. If your root layout's `generateViewport` depends on request data, [Use static viewport](#use-static-viewport) instead, or move to [`global-not-found.js`](/docs/app/api-reference/file-conventions/not-found#global-not-foundjs-experimental), which bypasses the root layout entirely and avoids inheriting its `generateViewport`.
......
This diff is collapsed.
......@@ -61,7 +61,7 @@ function CopyPromptButton({ prompt }: { prompt: string }) {
return (
<CopyButton
content={prompt}
actionLabel="Copy prompt"
actionLabel="Copy AI prompt"
successLabel="Prompt copied"
data-nextjs-fix-card-copy-button
/>
......
......@@ -284,20 +284,164 @@ describe('getBlockingRouteErrorDetails', () => {
})
describe('client hook guidance', () => {
it('only suggests Suspense for useSearchParams', () => {
it('shows Stream and Block cards for useSearchParams', () => {
const cards = getCards('client-hook', 'runtime', 'useSearchParams()')
expect(cards.map((card) => card.id)).toEqual([
'wrap-in-or-move-into-suspense',
'allow-blocking-route',
])
expect(cards.map((card) => card.group)).toEqual(['stream', 'block'])
})
it('shows Stream, GSP, and Block cards for useParams', () => {
const cards = getCards('client-hook', 'runtime', 'useParams()')
expect(cards.map((card) => card.id)).toEqual([
'wrap-in-or-move-into-suspense',
'for-known-params-prerender',
'allow-blocking-route',
])
expect(cards.map((card) => card.group)).toEqual([
'stream',
'cache',
'block',
])
})
it('shows Stream and Block cards for hooks without GSP', () => {
const expected = ['wrap-in-or-move-into-suspense', 'allow-blocking-route']
expect(
getCards('client-hook', 'runtime', 'usePathname()').map((c) => c.id)
).toEqual(expected)
expect(
getCards('client-hook', 'runtime', 'useSelectedLayoutSegment()').map(
(c) => c.id
)
).toEqual(expected)
expect(
getCards('client-hook', 'runtime', 'useSelectedLayoutSegments()').map(
(c) => c.id
)
).toEqual(expected)
})
})
describe('card sets for all error families', () => {
it('blocking-route runtime', () => {
expect(
getCards('blocking-route', 'runtime').map((card) => card.id)
).toEqual([
'wrap-in-or-move-into-suspense',
'for-known-params-prerender',
'allow-blocking-route',
])
})
it('blocking-route dynamic', () => {
expect(
getCards('blocking-route', 'dynamic').map((card) => card.id)
).toEqual([
'cache-the-component-or-data',
'wrap-in-or-move-into-suspense',
'allow-blocking-route',
])
})
it('metadata runtime', () => {
expect(getCards('metadata', 'runtime').map((card) => card.id)).toEqual([
'use-static-metadata',
'render-page-at-request-time',
])
})
it('metadata dynamic', () => {
expect(getCards('metadata', 'dynamic').map((card) => card.id)).toEqual([
'cache-the-metadata',
'render-page-at-request-time',
])
})
it('viewport runtime', () => {
expect(getCards('viewport', 'runtime').map((card) => card.id)).toEqual([
'use-static-viewport',
'allow-blocking-route',
])
})
it('viewport dynamic', () => {
expect(getCards('viewport', 'dynamic').map((card) => card.id)).toEqual([
'cache-viewport-data',
'allow-blocking-route',
])
})
it('unrendered-segment', () => {
expect(
getCards('unrendered-segment', 'runtime').map((card) => card.id)
).toEqual(['render-the-dropped-segment', 'skip-validation-on-the-segment'])
})
it('sync-io math', () => {
expect(
getCards('sync-io', 'runtime', 'Math.random()').map((card) => card.id)
).toEqual([
'render-at-request-time',
'cache-the-random-value',
'render-on-the-client',
])
})
it('sync-io date', () => {
expect(
getCards('sync-io', 'runtime', 'Date.now()').map((card) => card.id)
).toEqual([
'render-at-request-time',
'cache-the-timestamp',
'render-on-the-client',
'measure-elapsed-time',
])
})
it('sync-io crypto', () => {
expect(
getCards('client-hook', 'runtime', 'useSearchParams()').map(
getCards('sync-io', 'runtime', 'crypto.randomUUID()').map(
(card) => card.id
)
).toEqual(['wrap-in-or-move-into-suspense'])
).toEqual([
'render-at-request-time',
'cache-the-generated-value',
'render-on-the-client',
])
})
it('sync-io-client math', () => {
expect(
getCards('sync-io-client', 'runtime', 'Math.random()').map(
(card) => card.id
)
).toEqual([
'wrap-in-or-move-into-suspense',
'move-into-effect-or-event-handler',
])
})
it('also suggests prerendering known params for param-derived hooks', () => {
it('sync-io-client date', () => {
expect(
getCards('client-hook', 'runtime', 'useParams()').map((card) => card.id)
getCards('sync-io-client', 'runtime', 'Date.now()').map((card) => card.id)
).toEqual([
'wrap-in-or-move-into-suspense',
'move-into-effect-or-event-handler',
'measure-elapsed-time',
])
})
it('sync-io-client crypto', () => {
expect(
getCards('sync-io-client', 'runtime', 'crypto.randomUUID()').map(
(card) => card.id
)
).toEqual([
'wrap-in-or-move-into-suspense',
'prerender-known-dynamic-params',
'move-into-effect-or-event-handler',
])
})
})
......
......@@ -377,7 +377,9 @@ export function getBlockingRouteErrorDetails(
const inNavigation = isBlockingRouteInNavError(message)
const clientHookMatch =
/A Client Component used `([^`]+)` outside of `<Suspense>`\./.exec(message)
/Next\.js encountered URL data `([^`]+)` in a Client Component outside of `<Suspense>`\./.exec(
message
)
if (clientHookMatch) {
return {
type: 'client-hook',
......@@ -917,8 +919,9 @@ Next.js version: ${props.versionInfo.installed} (${process.env.__NEXT_BUNDLER})\
errorType={errorType}
errorMessage={
<>
A Client Component used <code>{errorDetails.expression}</code>{' '}
outside of <code>&lt;Suspense&gt;</code>.
Next.js encountered URL data{' '}
<code>{errorDetails.expression}</code> in a Client Component
outside of Suspense.
</>
}
headerChildren={<InstantHeaderExplanation kind="client-hook" />}
......
......@@ -5,7 +5,7 @@ export function createRuntimeBodyError(route: string): Error {
`Ways to fix this:\n` +
` - [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` +
` https://nextjs.org/docs/messages/blocking-prerender-runtime#wrap-in-or-move-into-suspense\n` +
` - [cache] If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`\n` +
` - [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender\n` +
` - [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route`
......@@ -17,10 +17,10 @@ export function createDynamicBodyError(route: string): Error {
`Route "${route}": Next.js encountered uncached data during prerendering.\n\n` +
`\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered, blocking the page load and leading to a slower user experience.\n\n` +
`Ways to fix this:\n` +
` - [cache] Cache the data access with \`"use cache"\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data\n` +
` - [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense\n` +
` - [cache] Cache the data access with \`"use cache"\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data\n` +
` - [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route`
)
......@@ -33,7 +33,7 @@ export function createRuntimeBodyErrorInNavigation(route: string): Error {
`Ways to fix this:\n` +
` - [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` +
` https://nextjs.org/docs/messages/blocking-prerender-runtime#wrap-in-or-move-into-suspense\n` +
` - [cache] If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`\n` +
` - [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender\n` +
` - [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route`
......@@ -45,10 +45,10 @@ export function createDynamicBodyErrorInNavigation(route: string): Error {
`Route "${route}": Next.js encountered uncached data during prerendering or a navigation.\n\n` +
`\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.\n\n` +
`Ways to fix this:\n` +
` - [cache] Cache the data access with \`"use cache"\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data\n` +
` - [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense\n` +
` - [cache] Cache the data access with \`"use cache"\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data\n` +
` - [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route`
)
......@@ -64,11 +64,11 @@ export function createDynamicOrRuntimeBodyError(route: string): Error {
`Route "${route}": Next.js encountered uncached or runtime data during prerendering.\n\n` +
`\`fetch(...)\`, \`cookies()\`, \`headers()\`, \`params\`, \`searchParams\`, or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered, blocking the page load and leading to a slower user experience.\n\n` +
`Ways to fix this:\n` +
` - [cache] Cache the data access with \`"use cache"\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data\n` +
` - [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense\n` +
` - [cache] If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`\n` +
` - [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data\n` +
` - [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender\n` +
` - [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route`
......@@ -131,11 +131,11 @@ export function createDynamicViewportError(route: string): Error {
export function createDynamicOrRuntimeViewportError(route: string): Error {
return new Error(
`Route "${route}": Next.js encountered uncached or runtime data in \`generateViewport()\`.\n\n` +
`This prevents the page from being prerendered, leading to a slower user experience.\n\n` +
`This prevents the page from being prerendered, leading to a slower user experience. Unlike metadata, viewport cannot be streamed behind \`<Suspense>\` because it affects the initial page load.\n\n` +
`Ways to fix this:\n` +
` - [static] Use a static viewport export instead of \`generateViewport()\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-viewport-runtime#use-static-viewport\n` +
` - [cache] Cache the viewport data with \`"use cache"\` in \`generateViewport()\`\n` +
` - [cache] For uncached data (\`fetch\`, database calls): cache the viewport with \`"use cache"\` in \`generateViewport()\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-viewport-dynamic#cache-the-viewport-data\n` +
` - [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-viewport-dynamic#allow-blocking-route`
......
......@@ -41,11 +41,13 @@ export class ClientHookDynamicError extends Error {
constructor(route: string, expression: string) {
super(
`Route "${route}": A Client Component used \`${expression}\` outside of \`<Suspense>\`.\n\n` +
`This prevents the route from being prerendered because the value is only available at runtime.\n\n` +
`Route "${route}": Next.js encountered URL data \`${expression}\` in a Client Component outside of \`<Suspense>\`.\n\n` +
`This blocks prerendering because the value is only available at runtime.\n\n` +
`Ways to fix this:\n` +
` - [stream] Wrap the Client Component in \`<Suspense fallback={...}>\`\n` +
` https://nextjs.org/docs/messages/next-prerender-client-hook#wrap-the-client-component-in-suspense`
` - [stream] Wrap the component in \`<Suspense fallback={...}>\` so the hook value streams in after prerendering\n` +
` https://nextjs.org/docs/messages/blocking-prerender-client-hook#wrap-in-or-move-into-suspense\n` +
` - [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-client-hook#allow-blocking-route`
)
}
}
......@@ -54,14 +56,20 @@ export class ParamClientHookDynamicError extends Error {
public readonly digest = CLIENT_HOOK_DYNAMIC
constructor(route: string, expression: string) {
const cacheBullet =
expression === 'useParams()'
? ` - [cache] For known params, prerender them with \`generateStaticParams\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-client-hook#for-known-params-prerender\n`
: ''
super(
`Route "${route}": A Client Component used \`${expression}\` outside of \`<Suspense>\`.\n\n` +
`This prevents the route from being prerendered because the value is only available at runtime.\n\n` +
`Route "${route}": Next.js encountered URL data \`${expression}\` in a Client Component outside of \`<Suspense>\`.\n\n` +
`This blocks prerendering because the value is only available at runtime.\n\n` +
`Ways to fix this:\n` +
` - [stream] Wrap the Client Component in \`<Suspense fallback={...}>\`\n` +
` https://nextjs.org/docs/messages/next-prerender-client-hook#wrap-the-client-component-in-suspense\n` +
` - [prerender] If the dynamic params are known, prerender them with \`generateStaticParams\`\n` +
` https://nextjs.org/docs/messages/next-prerender-client-hook#prerender-known-dynamic-params`
` - [stream] Wrap the component in \`<Suspense fallback={...}>\` so the hook value streams in after prerendering\n` +
` https://nextjs.org/docs/messages/blocking-prerender-client-hook#wrap-in-or-move-into-suspense\n` +
cacheBullet +
` - [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-client-hook#allow-blocking-route`
)
}
}
......
......@@ -98,7 +98,7 @@ describe('Cache Components Dev Errors', () => {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1290",
"code": "E1318",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......
......@@ -52,7 +52,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -67,7 +67,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -85,7 +85,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -100,7 +100,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -118,7 +118,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -133,7 +133,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -155,7 +155,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -170,7 +170,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -188,7 +188,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -203,7 +203,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -221,7 +221,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -236,7 +236,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -254,7 +254,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -269,7 +269,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -287,7 +287,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -302,7 +302,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -320,7 +320,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -335,7 +335,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1296",
"code": "E1320",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......
......@@ -126,7 +126,7 @@ describe('cache-components-dev-streaming', () => {
// Cold cache miss: validation runs against a separate warm-cache render.
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1290",
"code": "E1318",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -151,7 +151,7 @@ describe('cache-components-dev-streaming', () => {
// and the cached value is re-served rather than recomputed.
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1290",
"code": "E1318",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......
......@@ -69,10 +69,10 @@ describe('instant-validation-build', () => {
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
Ways to fix this:
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at main (<anonymous>)
......
......@@ -105,7 +105,7 @@ describe('instant validation causes', () => {
],
},
],
"code": "E1297",
"code": "E1319",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -136,7 +136,7 @@ describe('instant validation causes', () => {
],
},
],
"code": "E1297",
"code": "E1319",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -167,7 +167,7 @@ describe('instant validation causes', () => {
],
},
],
"code": "E1297",
"code": "E1319",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -201,7 +201,7 @@ describe('instant validation causes', () => {
],
},
],
"code": "E1297",
"code": "E1319",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......
......@@ -57,7 +57,7 @@ describe('instant validation - default level', () => {
const browser = await next.browser('/bare')
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......
......@@ -60,7 +60,7 @@ describe('instant validation - level error', () => {
const browser = await next.browser('/bare')
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -90,7 +90,7 @@ describe('instant validation - level error', () => {
],
},
],
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -120,7 +120,7 @@ describe('instant validation - level error', () => {
],
},
],
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -150,7 +150,7 @@ describe('instant validation - level error', () => {
],
},
],
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -177,7 +177,7 @@ describe('instant validation - level error', () => {
const browser = await next.browser('/layered')
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -202,10 +202,10 @@ describe('instant validation - level error', () => {
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
Ways to fix this:
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at a (<anonymous>)
......@@ -229,10 +229,10 @@ describe('instant validation - level error', () => {
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
Ways to fix this:
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at a (<anonymous>)
......@@ -256,10 +256,10 @@ describe('instant validation - level error', () => {
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
Ways to fix this:
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at a (<anonymous>)
......@@ -296,10 +296,10 @@ describe('instant validation - level error', () => {
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
Ways to fix this:
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at a (<anonymous>)
......
......@@ -79,7 +79,7 @@ describe('instant validation - level manual-error', () => {
],
},
],
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -109,7 +109,7 @@ describe('instant validation - level manual-error', () => {
],
},
],
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -139,7 +139,7 @@ describe('instant validation - level manual-error', () => {
],
},
],
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -185,10 +185,10 @@ describe('instant validation - level manual-error', () => {
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
Ways to fix this:
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at a (<anonymous>)
......@@ -212,10 +212,10 @@ describe('instant validation - level manual-error', () => {
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
Ways to fix this:
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at a (<anonymous>)
......
......@@ -93,7 +93,7 @@ describe('instant validation - level manual-warning', () => {
],
},
],
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -125,7 +125,7 @@ describe('instant validation - level manual-warning', () => {
],
},
],
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -157,7 +157,7 @@ describe('instant validation - level manual-warning', () => {
],
},
],
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -197,10 +197,10 @@ describe('instant validation - level manual-warning', () => {
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
Ways to fix this:
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at a (<anonymous>)
......@@ -230,7 +230,7 @@ describe('instant validation - level manual-warning', () => {
// did not run under 'manual-warning'.
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1290",
"code": "E1318",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -250,7 +250,7 @@ describe('instant validation - level manual-warning', () => {
)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1290",
"code": "E1318",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -270,7 +270,7 @@ describe('instant validation - level manual-warning', () => {
)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1290",
"code": "E1318",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -290,7 +290,7 @@ describe('instant validation - level manual-warning', () => {
)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1290",
"code": "E1318",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -336,11 +336,11 @@ describe('instant validation - level manual-warning', () => {
\`fetch(...)\`, \`cookies()\`, \`headers()\`, \`params\`, \`searchParams\`, or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered, blocking the page load and leading to a slower user experience.
Ways to fix this:
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
......@@ -364,11 +364,11 @@ describe('instant validation - level manual-warning', () => {
\`fetch(...)\`, \`cookies()\`, \`headers()\`, \`params\`, \`searchParams\`, or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered, blocking the page load and leading to a slower user experience.
Ways to fix this:
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
......@@ -394,11 +394,11 @@ describe('instant validation - level manual-warning', () => {
\`fetch(...)\`, \`cookies()\`, \`headers()\`, \`params\`, \`searchParams\`, or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered, blocking the page load and leading to a slower user experience.
Ways to fix this:
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
......@@ -428,11 +428,11 @@ describe('instant validation - level manual-warning', () => {
\`fetch(...)\`, \`cookies()\`, \`headers()\`, \`params\`, \`searchParams\`, or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered, blocking the page load and leading to a slower user experience.
Ways to fix this:
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
......
......@@ -60,7 +60,7 @@ describe('instant validation - level warning', () => {
const browser = await next.browser('/bare')
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -90,7 +90,7 @@ describe('instant validation - level warning', () => {
],
},
],
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -120,7 +120,7 @@ describe('instant validation - level warning', () => {
],
},
],
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -150,7 +150,7 @@ describe('instant validation - level warning', () => {
],
},
],
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -177,7 +177,7 @@ describe('instant validation - level warning', () => {
const browser = await next.browser('/layered')
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1298",
"code": "E1317",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -207,10 +207,10 @@ describe('instant validation - level warning', () => {
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
Ways to fix this:
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at a (<anonymous>)
......
......@@ -45,7 +45,7 @@ describe('instant validation', () => {
await browser.elementByCss('main')
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1290",
"code": "E1318",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......
......@@ -124,7 +124,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1297",
"code": "E1319",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -149,7 +149,7 @@ describe('instant validation - parallel slot configs', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-runtime#wrap-in-or-move-into-suspense
- [cache] If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route
......@@ -185,7 +185,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1297",
"code": "E1319",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -210,7 +210,7 @@ describe('instant validation - parallel slot configs', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-runtime#wrap-in-or-move-into-suspense
- [cache] If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route
......@@ -246,7 +246,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1297",
"code": "E1319",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -271,7 +271,7 @@ describe('instant validation - parallel slot configs', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-runtime#wrap-in-or-move-into-suspense
- [cache] If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route
......@@ -309,7 +309,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1297",
"code": "E1319",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -334,7 +334,7 @@ describe('instant validation - parallel slot configs', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-runtime#wrap-in-or-move-into-suspense
- [cache] If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route
......@@ -372,7 +372,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1297",
"code": "E1319",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -396,7 +396,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1297",
"code": "E1319",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -422,7 +422,7 @@ describe('instant validation - parallel slot configs', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-runtime#wrap-in-or-move-into-suspense
- [cache] If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route
......@@ -437,7 +437,7 @@ describe('instant validation - parallel slot configs', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-runtime#wrap-in-or-move-into-suspense
- [cache] If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route
......@@ -541,7 +541,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1297",
"code": "E1319",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -564,7 +564,7 @@ describe('instant validation - parallel slot configs', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-runtime#wrap-in-or-move-into-suspense
- [cache] If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const unstable_instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route
......@@ -635,7 +635,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1297",
"code": "E1319",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......
......@@ -26,7 +26,7 @@ describe('missing-suspense-with-csr-bailout', () => {
describe('useSearchParams', () => {
const message = isCacheComponentsEnabled
? 'https://nextjs.org/docs/messages/next-prerender-client-hook#wrap-the-client-component-in-suspense'
? 'https://nextjs.org/docs/messages/blocking-prerender-client-hook#wrap-in-or-move-into-suspense'
: `useSearchParams() should be wrapped in a suspense boundary at page "/".`
it('should fail build if useSearchParams is not wrapped in a suspense boundary', async () => {
......
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