Partial Prefetching changes what a <Link> downloads for a Cache Components route. With Partial Prefetching enabled, a <Link> prefetches the route's App Shell: its static content and the cached content that doesn't depend on the URL. Next.js builds one App Shell per route and reuses it for every link to that route, rather than prefetching each link separately as it did before.
To prefetch more than the App Shell, a route can opt into runtime prefetching with prefetch = 'allow-runtime'. The prefetch then also resolves the per-link runtime data (params, searchParams, and the full URL) and the cached content behind it.
Along the way, Next.js surfaces instant navigation insights in development, naming the link or route to change.
Good to know: Partial Prefetching only works when
cacheComponentsis enabled.
What changes for <Link>
<Link> prop |
Before (Cache Components default) | After Partial Prefetching |
|---|---|---|
<Link href="/x"> |
Prefetched the cached page render. | Loads the shared App Shell for /x. |
<Link href="/x" prefetch> |
Prefetched the cached page render and any dynamic content. | Loads the App Shell. If /x opts into runtime prefetching, also prefetches per-link runtime data. |
<Link href="/x" prefetch={false}> |
Disabled prefetching for this link. | Unchanged. Still disabled. |
The App Shell is shared across every link to a given route, regardless of dynamic params, so rendering many <Link>s to the same destination doesn't multiply the work.
Use the adoption skill (recommended)
The next-partial-prefetching-adoption skill drives this adoption with a coding agent. It audits your <Link prefetch={true}> calls with you, enables the flag, and sweeps every route for the insights this guide covers.
Install the skill:
npx skills add vercel/next.js --skill next-partial-prefetching-adoption
Then give the agent this prompt:
Adopt Partial Prefetching in this project using the next-partial-prefetching-adoption skill.
Or adopt by hand
Adopting an existing app by hand follows the two instant navigation insights Next.js surfaces in next dev:
- Enable
partialPrefetching, then audit every<Link prefetch={true}>and decide per destination how to preserve what its prefetch delivered. When the adoption is large enough that reviewers need smaller diffs, or adopted routes should reach users before the rest, adopt incrementally with the flag off, guided by the dynamic data during prefetching insight. - Audit routes for URL data, resolving the URL data outside of Suspense insight.
- Optionally, prefetch URL data on the routes where streaming in after navigation isn't enough.
Both insights are development-only and never block the build. They appear in the dev overlay with fix cards that link the docs page for each fix. If a route isn't ready to adopt, export instant = false from its page or layout to opt the route out of instant-navigation validation, and return to it later.
Enable Partial Prefetching
Enable partialPrefetching in next.config.ts:
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
cacheComponents: true,
partialPrefetching: true,
}
export default nextConfig
After enabling the flag, every <Link> prefetches its destination's App Shell, and <Link prefetch={true}> no longer includes the route's dynamic content. Audit those links next to preserve what they delivered. A new project has no legacy links to audit and is done here.
Auditing <Link prefetch={true}> calls
Each <Link prefetch={true}> used to prefetch its destination's dynamic content along with the page. With the flag on it loads the App Shell like every other link, which can be thinner than the old full prefetch. Go through each one and decide what the destination should still prefetch:
Good to know:
cookies()andheaders()don't tie a prefetch to a URL. They vary per session, not per link, so the App Shell still carries session content. OnlyparamsandsearchParamsare URL data, which varies per link and can't be included in the shared App Shell.
| Destination | Recommendation |
|---|---|
| Fully static, or content already cached | Remove the now-redundant prefetch={true}. |
| Delivered uncached content you want kept ahead of the click | Cache it with use cache, then remove prefetch={true}. |
Delivered content that depends on cookies() or headers() |
Cache the lookup behind the session value, then remove prefetch={true}. |
| Reads URL data, or has cached content that depends on it | Keep prefetch={true}, and prefetch the content later with runtime prefetching. |
| Delivers real-time content that must stay fresh per request | Remove prefetch={true} and let the content stream in. |
Static or cached content
The output is already in the App Shell. Remove the now-redundant prefetch={true}:
// Before
<Link href="/about" prefetch={true}>About</Link>
// After
<Link href="/about">About</Link>
Uncached content
Cache it with use cache so it gets included in the App Shell, then remove prefetch={true} from the links:
// Before
export default async function Page() {
const res = await fetch('https://api.example.com/products')
return <ProductList products={await res.json()} />
}
// Before
export default async function Page() {
const res = await fetch('https://api.example.com/products')
return <ProductList products={await res.json()} />
}
// After - cached, so the App Shell carries it
async function getProducts() {
'use cache'
const res = await fetch('https://api.example.com/products')
return res.json()
}
export default async function Page() {
return <ProductList products={await getProducts()} />
}
// After - cached, so the App Shell carries it
async function getProducts() {
'use cache'
const res = await fetch('https://api.example.com/products')
return res.json()
}
export default async function Page() {
return <ProductList products={await getProducts()} />
}
Session content
Content behind cookies() or headers() varies per session, not per link, and session data resolves in the App Shell, so cached session content still gets included. Read the session value outside the cached function and pass it in, then remove prefetch={true} from the links:
// Before
import { Suspense } from 'react'
import { cookies } from 'next/headers'
async function TeamTopics() {
const team = (await cookies()).get('team')?.value
const topics = await db.topics.forTeam(team)
return <TopicList topics={topics} />
}
export default function Page() {
return (
<Suspense fallback={<Skeleton />}>
<TeamTopics />
</Suspense>
)
}
// Before
import { Suspense } from 'react'
import { cookies } from 'next/headers'
async function TeamTopics() {
const team = (await cookies()).get('team')?.value
const topics = await db.topics.forTeam(team)
return <TopicList topics={topics} />
}
export default function Page() {
return (
<Suspense fallback={<Skeleton />}>
<TeamTopics />
</Suspense>
)
}
// After - the lookup is cached behind the session value
import { Suspense } from 'react'
import { cookies } from 'next/headers'
async function getTopics(team: string | undefined) {
'use cache'
return db.topics.forTeam(team)
}
async function TeamTopics() {
const team = (await cookies()).get('team')?.value
return <TopicList topics={await getTopics(team)} />
}
export default function Page() {
return (
<Suspense fallback={<Skeleton />}>
<TeamTopics />
</Suspense>
)
}
// After - the lookup is cached behind the session value
import { Suspense } from 'react'
import { cookies } from 'next/headers'
async function getTopics(team) {
'use cache'
return db.topics.forTeam(team)
}
async function TeamTopics() {
const team = (await cookies()).get('team')?.value
return <TopicList topics={await getTopics(team)} />
}
export default function Page() {
return (
<Suspense fallback={<Skeleton />}>
<TeamTopics />
</Suspense>
)
}
URL data
URL data (params, searchParams) varies per link, so content that depends on it can't be included in the shared App Shell and streams in after navigation from behind its <Suspense> boundary. The links keep prefetch={true}, and Prefetching URL data covers prefetching the content ahead of the click.
Real-time content
A prefetch of real-time content would be stale by the click, so there is nothing to preserve. Remove prefetch={true} and let the content stream in from behind its <Suspense> boundary.
Adopting incrementally
Adoption doesn't have to happen in one change. prefetch = 'partial' is the global flag scoped to one route, so with the global flag still off, you can adopt and deploy each destination on its own.
While the flag is off, prefetch={true} still performs the legacy full prefetch. Navigating through one of these links in development surfaces the dynamic data during prefetching insight, naming the destination and pointing at its fixes:
Each card is clickable and opens a page with patterns, code samples, and trade-offs.
-
Audit one destination, preserving what its prefetch delivered and updating its links'
prefetch={true}per the table above. Then adopt it by addingexport const prefetch = 'partial'to its page or layout, which clears the insight for every link pointing at the route:// Before export default function Page() { return <Dashboard /> }// Before export default function Page() { return <Dashboard /> }// After - adopted without the global flag export const prefetch = 'partial' export default function Page() { return <Dashboard /> }// After - adopted without the global flag export const prefetch = 'partial' export default function Page() { return <Dashboard /> } -
Deploy the change. Links to the adopted destination load the App Shell, and the insight keeps firing for the destinations you haven't reached.
-
Repeat until every destination in scope is adopted, then enable the flag.
The per-route prefetch = 'partial' exports are now redundant. Remove them in one pass with the remove-partial-prefetch codemod, which strips export const prefetch = 'partial' from every page and layout:
npx @next/codemod@canary remove-partial-prefetch ./app
The codemod removes only the 'partial' value and leaves other values such as prefetch = 'allow-runtime' in place.
Auditing routes for URL data
With the flag enabled, Next.js validates each App Shell as you navigate in development. The App Shell is shared across every link to a route, so it can't contain data that belongs to a single URL. Reading params or searchParams outside a <Suspense> boundary ties the shell to the link's URL and surfaces the URL data outside of Suspense insight, naming the route and pointing at its fixes:
The insight never blocks the build, so this pass can happen any time after the flag is on. Load every route in next dev to check for it.
The fix is to keep the URL-independent parts of the route outside the boundary and move the params or searchParams read into a child wrapped in <Suspense>:
// Before - awaiting params at the top ties the App Shell to one URL
export default async function Page({ params }: PageProps<'/products/[slug]'>) {
const { slug } = await params
const product = await getProduct(slug)
return (
<ProductLayout>
<Details product={product} />
</ProductLayout>
)
}
// Before - awaiting params at the top ties the App Shell to one URL
export default async function Page({ params }) {
const { slug } = await params
const product = await getProduct(slug)
return (
<ProductLayout>
<Details product={product} />
</ProductLayout>
)
}
// After - pass the promise down without awaiting it
import { Suspense } from 'react'
import { ProductDetails } from './product-details'
export default function Page({ params }: PageProps<'/products/[slug]'>) {
return (
<ProductLayout>
<Suspense fallback={<DetailsSkeleton />}>
<ProductDetails params={params} />
</Suspense>
</ProductLayout>
)
}
// After - pass the promise down without awaiting it
import { Suspense } from 'react'
import { ProductDetails } from './product-details'
export default function Page({ params }) {
return (
<ProductLayout>
<Suspense fallback={<DetailsSkeleton />}>
<ProductDetails params={params} />
</Suspense>
</ProductLayout>
)
}
The child awaits the promise inside the boundary:
export async function ProductDetails({
params,
}: Pick<PageProps<'/products/[slug]'>, 'params'>) {
const { slug } = await params
const product = await getProduct(slug)
return <Details product={product} />
}
export async function ProductDetails({ params }) {
const { slug } = await params
const product = await getProduct(slug)
return <Details product={product} />
}
Everything outside the boundary stays in the shared App Shell, and only the URL-specific region renders per navigation. Load or navigate to the route again to confirm the insight is gone and the page still paints meaningful UI.
Good to know: A
paramsorsearchParamsread insidegenerateMetadatasurfaces as URL data ingenerateMetadata()instead.
Prefetching URL data
Content that depends on URL data (params, searchParams) can't be included in the shared App Shell, so it streams in after navigation. Runtime prefetching resolves it ahead of the click for links with prefetch={true}, at the cost of a server invocation per prefetchable link. To opt a route in, cache the content behind the read with use cache so it can resolve at prefetch time, then add prefetch = 'allow-runtime'. For a search page that reads searchParams:
// Before - the results stream in after navigation
import { Suspense } from 'react'
async function getResults(query: string) {
const res = await fetch(`https://api.example.com/search?q=${query}`)
return res.json()
}
async function Results({
searchParams,
}: Pick<PageProps<'/search'>, 'searchParams'>) {
const { q } = await searchParams
return <ResultList results={await getResults(q)} />
}
export default function Page({ searchParams }: PageProps<'/search'>) {
return (
<Suspense fallback={<Skeleton />}>
<Results searchParams={searchParams} />
</Suspense>
)
}
// Before - the results stream in after navigation
import { Suspense } from 'react'
async function getResults(query) {
const res = await fetch(`https://api.example.com/search?q=${query}`)
return res.json()
}
async function Results({ searchParams }) {
const { q } = await searchParams
return <ResultList results={await getResults(q)} />
}
export default function Page({ searchParams }) {
return (
<Suspense fallback={<Skeleton />}>
<Results searchParams={searchParams} />
</Suspense>
)
}
// After - the results are cached and prefetched behind the resolved searchParams
import { Suspense } from 'react'
export const prefetch = 'allow-runtime'
async function getResults(query: string) {
'use cache'
const res = await fetch(`https://api.example.com/search?q=${query}`)
return res.json()
}
async function Results({
searchParams,
}: Pick<PageProps<'/search'>, 'searchParams'>) {
const { q } = await searchParams
return <ResultList results={await getResults(q)} />
}
export default function Page({ searchParams }: PageProps<'/search'>) {
return (
<Suspense fallback={<Skeleton />}>
<Results searchParams={searchParams} />
</Suspense>
)
}
// After - the results are cached and prefetched behind the resolved searchParams
import { Suspense } from 'react'
export const prefetch = 'allow-runtime'
async function getResults(query) {
'use cache'
const res = await fetch(`https://api.example.com/search?q=${query}`)
return res.json()
}
async function Results({ searchParams }) {
const { q } = await searchParams
return <ResultList results={await getResults(q)} />
}
export default function Page({ searchParams }) {
return (
<Suspense fallback={<Skeleton />}>
<Results searchParams={searchParams} />
</Suspense>
)
}
The runtime prefetching guide covers when the cost pays off and the caching patterns behind runtime reads.
Source: docs/01-app/02-guides/adopting-partial-prefetching.mdx