Support bot and method-based prerender bypass capabilities (#101911)
HTML-limited bots currently bypass Cache Components prerenders even when
metadata is complete. Server Action header conditions can also bypass
the cache for read requests. This change adds independent adapter
capabilities so Next.js can generate appropriate prerender conditions
for both paths.
The optional, synchronous `getCapabilities({ config })` hook receives
resolved app configuration after `modifyConfig`.
`supportsHtmlLimitedBotPrerenders` declares that matching user agents
receive complete metadata in the initial HTML head.
`supportsPrerenderMethodBypass` declares support for HTTP method
conditions. Next.js removes its generated bot condition and replaces its
action-header/multipart pair with a POST condition after the
corresponding opt-in. Other conditions and non-App-Page outputs retain
their behavior.
Next.js marks nonempty HTML prerenders whose metadata is omitted with
`x-next-prelude-metadata: 0`, including recovery shells. Next.js
excludes that marker from adapter RSC and segment outputs and from
cached RSC delivery. The paired adapter change in
https://github.com/nextjs/adapter-vercel/pull/168 emits the
deployment-level policy and serializes the final per-route conditions
unchanged.
The Vercel adapter declines the bot capability when a configured regex
exceeds the deployment matcher's UTF-8 byte limit. Next.js then
preserves the old per-route bot condition, independently of method
support. Missing hooks and omitted or false flags also preserve existing
conditions. Older Next.js ignores the hook, and the legacy builder's
manifest retains its existing rules. No Next.js version check is needed.
Coverage includes independent and combined capabilities, resolved
configuration after modification, legacy manifests, recovery HTML, RSC
regeneration, browser segment-prefetch reuse with a wildcard bot
pattern, and oversized custom patterns.
Closes #97650
The full deploy matrix exercises the paired Next.js and Vercel adapter
previews, including the HTML-limited bot and Server Action regressions.
[View the
run](https://github.com/vercel/next.js/actions/runs/44516113039).