Skip to content

Commit ccb3465

Browse files
fix(next/client): add prerender opt-out to PrefetchCrossZoneLinks
Adds a `prerender?: boolean` prop (default `true`) to `<PrefetchCrossZoneLinks />`. When `false`, the component emits only the `prefetch:` rules and omits the `prerender:` block from the `<script type="speculationrules">` JSON. Cross-zone prefetch is unchanged. Escape hatch for consumers seeing Chromium prerender-activation crashes on cross-deployment same-origin navigations (Chrome 147+). Default behavior unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent af86bf9 commit ccb3465

2 files changed

Lines changed: 30 additions & 6 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@vercel/microfrontends": minor
3+
---
4+
5+
`<PrefetchCrossZoneLinks />`: add `prerender?: boolean` prop (default `true`). When `false`, only `prefetch:` rules are emitted and the `prerender:` block is omitted entirely; cross-zone prefetch behavior is unchanged.
6+
7+
Escape hatch for consumers hit by Chromium prerender-activation crashes on cross-deployment same-origin navigations (Chrome 147+). Default behavior is unchanged.

packages/microfrontends/src/next/client/prefetch/prefetch-cross-zone-links.tsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,23 @@ interface PrefetchCrossZoneLinksProps {
6464
* Default value is 'conservative'.
6565
*/
6666
prerenderEagerness?: 'immediate' | 'eager' | 'moderate' | 'conservative';
67+
/**
68+
* Whether to emit a `prerender:` speculation rule alongside `prefetch:`.
69+
* When `false`, only `prefetch:` rules are emitted; cross-zone prefetch
70+
* is unaffected.
71+
*
72+
* Escape hatch for Chromium prerender activation crashes seen on
73+
* cross-deployment same-origin navigations (Chrome 147+). Remove once
74+
* the upstream Chromium issue is fixed.
75+
*
76+
* Default value is `true`.
77+
*/
78+
prerender?: boolean;
6779
}
6880

6981
export function PrefetchCrossZoneLinks({
7082
prerenderEagerness = 'conservative',
83+
prerender = true,
7184
}: PrefetchCrossZoneLinksProps): JSX.Element | null {
7285
const { isLoading } = useClientConfig(
7386
process.env.NEXT_PUBLIC_MFE_CLIENT_CONFIG,
@@ -172,12 +185,16 @@ export function PrefetchCrossZoneLinks({
172185
where: PREFETCH_WHEN_VISIBLE_PREDICATES,
173186
},
174187
],
175-
prerender: [
176-
{
177-
eagerness: prerenderEagerness,
178-
where: PREFETCH_ON_HOVER_PREDICATES,
179-
},
180-
],
188+
...(prerender
189+
? {
190+
prerender: [
191+
{
192+
eagerness: prerenderEagerness,
193+
where: PREFETCH_ON_HOVER_PREDICATES,
194+
},
195+
],
196+
}
197+
: {}),
181198
};
182199

183200
return (

0 commit comments

Comments
 (0)