Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
a92d806a
Unverified
Commit
a92d806a
authored
Sep 04, 2026
by
Hendrik Liebau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid legacy prerenders with runtime variant values
parent
89a9ad12
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
7 deletions
+72
-7
app-page-runtime.ts
packages/next/src/build/templates/app-page-runtime.ts
+5
-7
page.tsx
.../fixtures/default/app/conditional-runtime/[slug]/page.tsx
+37
-0
proxy.ts
test/e2e/app-dir/variants/fixtures/default/proxy.ts
+2
-0
variants.test.ts
test/e2e/app-dir/variants/variants.test.ts
+28
-0
No files found.
packages/next/src/build/templates/app-page-runtime.ts
View file @
a92d806a
...
@@ -613,14 +613,12 @@ export function createAppPageEntrypoint({
...
@@ -613,14 +613,12 @@ export function createAppPageEntrypoint({
const
supportsRDCForNavigations
=
const
supportsRDCForNavigations
=
isRoutePPREnabled
&&
nextConfig
.
cacheComponents
===
true
isRoutePPREnabled
&&
nextConfig
.
cacheComponents
===
true
// A static variant combination no page declared is served from the
// A non-PPR prerender cannot leave runtime-tier variant values as holes. A
// prerender that omits the variants, and a route that is not partially
// request that carries any must use a request render, even when it matched
// prerendered has none: omitting a variant leaves a hole only a resume can
// a static combination. Otherwise a legacy prerender finds no static value
// fill. Such a request is rendered dynamically instead. Without this it
// for the variant and interrupts the render.
// would take the static path, where a variant read finds no value and
// interrupts the render.
const
requiresDynamicResponseForVariants
=
Boolean
(
const
requiresDynamicResponseForVariants
=
Boolean
(
!
isRoutePPREnabled
&&
variantCombinationGroups
?.
length
&&
!
matchedVariants
!
isRoutePPREnabled
&&
runtimeVariants
!==
undefined
)
)
// In development, we always want to generate dynamic HTML.
// In development, we always want to generate dynamic HTML.
...
...
test/e2e/app-dir/variants/fixtures/default/app/conditional-runtime/[slug]/page.tsx
0 → 100644
View file @
a92d806a
import
{
Suspense
}
from
'react'
import
{
banner
,
theme
}
from
'../../../variants'
export
function
generateStaticParams
()
{
return
[{
slug
:
'built'
}]
}
export
function
unstable_generateStaticVariants
()
{
return
[[[
theme
,
'dark'
]],
[[
theme
,
'light'
]]]
}
async
function
Banner
()
{
return
<
p
id=
"banner"
>
{
await
banner
()
}
</
p
>
}
export
default
async
function
Page
({
params
,
}:
{
params
:
Promise
<
{
slug
:
string
}
>
})
{
const
{
slug
}
=
await
params
return
(
<>
<
p
id=
"slug"
>
{
slug
}
</
p
>
<
Suspense
fallback=
{
<
p
id=
"theme"
>
pending
</
p
>
}
>
<
p
id=
"theme"
>
{
theme
()
}
</
p
>
</
Suspense
>
{
slug
===
'runtime'
?
(
<
Suspense
fallback=
{
<
p
id=
"banner"
>
pending
</
p
>
}
>
<
Banner
/>
</
Suspense
>
)
:
null
}
</>
)
}
test/e2e/app-dir/variants/fixtures/default/proxy.ts
View file @
a92d806a
...
@@ -12,6 +12,7 @@ import { banner, locale, theme } from './variants'
...
@@ -12,6 +12,7 @@ import { banner, locale, theme } from './variants'
// route renders.
// route renders.
const
variantsByRoute
=
{
const
variantsByRoute
=
{
'/'
:
[
banner
,
locale
,
theme
],
'/'
:
[
banner
,
locale
,
theme
],
'/conditional-runtime/[slug]'
:
[
banner
,
theme
],
'/enumerated/[slug]'
:
[
locale
,
theme
],
'/enumerated/[slug]'
:
[
locale
,
theme
],
'/on-demand/[slug]'
:
[
banner
,
theme
],
'/on-demand/[slug]'
:
[
banner
,
theme
],
'/paramless'
:
[
locale
,
theme
],
'/paramless'
:
[
locale
,
theme
],
...
@@ -54,6 +55,7 @@ export const config = {
...
@@ -54,6 +55,7 @@ export const config = {
'/'
,
'/'
,
'/rewrite-source'
,
'/rewrite-source'
,
'/external'
,
'/external'
,
'/conditional-runtime/:slug'
,
'/enumerated/:slug'
,
'/enumerated/:slug'
,
'/shell/:slug'
,
'/shell/:slug'
,
'/on-demand/:slug'
,
'/on-demand/:slug'
,
...
...
test/e2e/app-dir/variants/variants.test.ts
View file @
a92d806a
...
@@ -480,6 +480,34 @@ describe('variants', () => {
...
@@ -480,6 +480,34 @@ describe('variants', () => {
expect
(
light
(
'#theme'
).
text
()).
toBe
(
'light'
)
expect
(
light
(
'#theme'
).
text
()).
toBe
(
'light'
)
})
})
it
(
'should render an unknown param dynamically when it reads a runtime variant'
,
async
()
=>
{
if
(
isNextStart
)
{
const
response
=
await
next
.
fetch
(
url
(
'/conditional-runtime/built'
),
{
headers
:
{
cookie
:
'theme=dark'
},
})
expect
(
response
.
headers
.
get
(
'x-nextjs-cache'
)).
toBe
(
'HIT'
)
}
for
(
const
banner
of
[
'first'
,
'second'
])
{
const
browser
=
await
next
.
browser
(
url
(
'/conditional-runtime/runtime'
),
{
async
beforePageLoad
(
page
:
Playwright
.
Page
)
{
await
page
.
context
().
addCookies
([
{
name
:
'theme'
,
value
:
'dark'
,
url
:
next
.
url
},
{
name
:
'banner'
,
value
:
banner
,
url
:
next
.
url
},
])
},
})
await
retry
(
async
()
=>
{
expect
(
await
browser
.
elementByCss
(
'#theme'
).
text
()).
toBe
(
'dark'
)
expect
(
await
browser
.
elementByCss
(
'#banner'
).
text
()).
toBe
(
banner
)
})
expect
(
await
browser
.
elementByCss
(
'#slug'
).
text
()).
toBe
(
'runtime'
)
}
})
it
(
'should prerender a fallback shell per variant combination'
,
async
()
=>
{
it
(
'should prerender a fallback shell per variant combination'
,
async
()
=>
{
// `shell/[slug]` declares no static params, so its fallback shell is the
// `shell/[slug]` declares no static params, so its fallback shell is the
// only thing prerendered for it. That shell reads a variant above the
// only thing prerendered for it. That shell reads a variant above the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment