vercel/next.js/next-cache-components-adoption
Claude Code and agent skill by vercel/next.js
- vendor
Checking that the SKILL.md file is still in the repository.
Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the `cacheComponents` flag, work through a flood of blocking-prerender / instant validation errors, run the `cache-components-instant-false` codemod, or decide between opting routes out with `export const instant = false` and fixing them in place.
Install
npx vskill@latest install vercel/next.js/next-cache-components-adoptionSKILL.md
The same SKILL.md was published earlier as vercel/next.js/next-cache-components-adoption.
next-cache-components-adoption
Enable Cache Components on an app and walk it to a passing build. This skill sequences the work; per-error recipes live in the dev overlay fix cards and the build's terminal output. The migrating to Cache Components guide is the canonical reference for the concepts and per-API recipes this skill applies — consult it whenever the skill steps reference a pattern ("use cache", cacheLife, <Suspense> placement, etc.) and you want the full explanation.
requires
- App Router project. Cache Components is an App Router feature;
cacheComponents: truedoes nothing forpages/routes. If the project has apages/orsrc/pages/tree but noapp/orsrc/app/tree, stop and tell the user — Pages → App migration is its own project, not part of this skill. A hybrid app (bothpages/andapp/) is fine: the flag affects theapp/routes;pages/routes are unaffected and don't need opt-outs.
- A resolved app directory. Locate
next.config.{js,ts,mjs,cjs}first: that's the project root, and an agent invoked from a subdirectory would otherwise test forapp/against the wrongcwdand find nothing. Look forapp/andsrc/app/under it, and treat every command and glob in this skill as relative to whichever one exists. If both exist, Next.js buildsapp/and never looks atsrc/app/, so its routes are shadowed and unbuilt — tell the user that and ask which tree to migrate instead of picking one.
- A runnable app. The whole loop verifies against
next devand a browser, so the app has to boot. If it reads a database or required env at import (e.g. anenv.tsthat throws on a missingDATABASE_URL), confirm it actually starts — with the real environment, or local data you stand up — before step 1. Adoption can't be verified against an app that won't run.
- Next.js 16.3 or later. That release is where the pieces this skill relies on land: top-level
cacheComponents,export const instant, the dev-overlay instant-navigation validation warnings, and thecache-components-instant-falsecodemod. Ifnext --versionreports below 16.3, upgrade first: npx @next/codemod@latest upgrade latestto apply the version-to-version codemods.- Read the relevant version upgrade guide (e.g. Version 16) for what the codemod doesn't cover.
- No incompatible config keys.
cacheComponents: trueerrors on any file that still exportsdynamic,revalidate, orfetchCache. Inventory these exports before running the codemod, then follow the migration guide's per-key sections. The guide is the source of truth for translating each value. Thecache-components-instant-falsecodemod does not remove these configs.
- `experimental.dynamicIO` is fatal. It was renamed to top-level
cacheComponentsand the old key now aborts before any build can run — remove it (or replace withcacheComponents: true) first.experimental.useCacheis still accepted as a deprecated alias; redundant oncecacheComponents: trueis set, so remove it for clarity.
notes
- No passing baseline before the flag. If the app already uses
"use cache", the pre-flag build errors withplease enable the feature flag cacheComponents. Enabling the flag is the first thing you do (in Incremental, before the codemod; in Direct, before fixing routes) — not a thing to do _after_ getting a passing build. Note this in your starting summary so it doesn't read as a regression.
- Existing caches can stay. Follow the migration guide's `fetch` and `unstable_cache` sections. Do not rewrite them solely to enable Cache Components.
- Offline docs. Guide links have offline copies under
node_modules/next/dist/docs/(bundled since Next.js 16.2), with the directory layout numbered for ordering (e.g.node_modules/next/dist/docs/01-app/02-guides/migrating-to-cache-components.md). If you can't predict the numbered prefix,find node_modules/next/dist/docs -name '<slug>.md'resolves it. The/docs/messages/*error pages are not bundled.
- Older versions without bundled docs. Suggest
npx @next/codemod@latest agents-mdto the user before starting: it downloads a version-matched copy to.next-docs/and writes an index intoAGENTS.md. It touches files in their repo, so ask first and run it only if they want it.
the shape of the work
There's one loop: walk the route tree top-down, one feature at a time, adopting each route against next dev + a browser. The build is a final check for each feature, not the working surface.
The choice in step 1 is whether to opt every route out of validation first or fix routes as you go. Either way the loop is the same:
- With a quiet pre-step (Incremental). Run the codemod, fix what it can't, and fully migrate routes that previously required static rendering. Other routes keep their opt-outs for follow-up PRs.
- Without (Direct). Enable
cacheComponentsand start the loop on whatever the build flags first. Same loop, but every fix sits on one branch until adoption is complete.
In both, the per-route success bar is the same: dev loop reports no errors AND `next build` passes. Check in with the user after every feature, and suggest a commit but never make one without their confirmation. Expect to spend most of the time in the loop, not in the pre-step.
background
cacheComponents: true requires every route to be prerenderable. A route that reads request-time data outside <Suspense> is "blocking" and fails the build. export const instant = false marks a route as allowed to block, which clears it in both dev and build; on a layout it covers the whole subtree during the build, but client navigations still validate each descendant segment on its own. Reads wrapped in a `"use cache"` function count as cache boundaries, not blocking reads.
When a fix introduces "use cache", follow the Caching guide for choosing a data-level or UI-level boundary and setting its lifetime and revalidating after mutations. Use the `use cache` cache-key reference when the result varies by arguments or captured values.
Three classes of blocker come up, usually in this order:
Whenever a fix introduces <Suspense>, follow the Streaming guide's granular streaming pattern and guidance for preventing CLS.
- Request-time reads (
cookies(),headers(),await params,await searchParams). All four block when awaited at the top of a page or layout.paramsandsearchParamsoften get missed because they're not framed as "request data" the way cookies and headers are. The fix is to push the read into a<Suspense>-wrapped child — and forparams/searchParams, forward the promise into the child and await it there; don'tawaitat the page top. - Sync-IO at module/render time (
new Date(),Date.now(),Math.random(),crypto.randomUUID()). These fail the build even withinstant = false— the opt-out doesn't suppress them. If they're in a shared layout, they block every route under it. The codemod can't fix them; after running it, use each build error and its linked documentation to identify which reported calls to translate by hand (see the incremental pre-step). - `"use cache"` files that read request data. A file with a top-level
"use cache"directive can't exportinstant; combining the two errors withOnly async functions are allowed to be exported in a "use cache" file., which means the directive was wrong for that route. Remove it before running the codemod.
working surfaces
finding blocking routes
Prefer next dev over next build while you work.
- `next dev` — the working surface. Visit a route; its blocking errors surface in the dev overlay with full stack traces and fix cards linking the per-error docs. Work one route at a time — errors don't accumulate in one place. The route itself still returns HTTP 200, so read the overlay (or
.next-dev.log), not status codes. A cleared overlay is one half of calling a route clean — the other half is browser verification (see step 2) and a passing build for that route. - `next build` — detection only. The build is
next dev's authoritative check, not its replacement. Use it as the last gate on each feature in the loop (a passing build is part of the per-route success bar) and as the final verification across the whole app. In Incremental, the build also confirms the pre-step (codemod opted every route out, no shared layout still has a sync-IO blocker) before you ship that PR. Don't reach for the build instead of the dev loop while you're working a route — a passing compile doesn't tell you what ended up in the static shell and what streamed. By default the build stops at the first blocking route, so it's also poor for sizing the work. Two flags help when iterating:--debug-build-pathsbuilds only the routes you name (comma-separated glob patterns of file paths relative to the project root, e.g.--debug-build-paths="app/admin/**/page.tsx"— not URL paths;--debug-build-paths="app/(marketing)/about/page.tsx"— not/about;--debug-build-paths="app/admin"matches nothing and silently builds zero routes), and--debug-prerenderdisables the early exit so the build continues past the first prerender failure, reports every blocking route, and prints a fuller stack trace that names the originating file and line.
Every blocking error has a docs page — open it. Both the dev overlay and the build terminal print a https://nextjs.org/docs/messages/<slug> link with each error. That page is the canonical recipe for the fix; the inline message is a summary. Fetch the link for every distinct error you encounter, even if you think you know the pattern — the recipes evolve, and the same error class can have different correct fixes depending on what the route reads. Don't improvise from the inline message alone. (/docs/messages/* pages aren't bundled offline; if you have no network, fall back to the per-API guides under node_modules/next/dist/docs/ and note the limitation when you report back.)
verifying each fix at runtime
A passing build or a cleared overlay isn't proof the route actually behaves — Cache Components is a runtime concern (a static shell with streamed data). Verify after every fix, not only at the end.
In preference order:
- [`next-dev-loop`](https://github.com/vercel/next.js/tree/canary/skills/next-dev-loop) — strongly preferred. Cross-checks
/_next/mcpagainst the live browser viaagent-browserand surfaces both compile and runtime issues in one pass. The diagnostics (React tree, suspense boundaries, console + network) are richer than poking atnext devby hand.
Install it before starting the loop. Don't wait until you hit something next dev alone can't explain. It ships alongside this skill, so check whether it is already available first, and install it only if it is not:
``bash npx skills add https://github.com/vercel/next.js/tree/canary/skills/next-dev-loop ``
The skill states its required agent-browser version and walks you through it.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 24 Nov 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/next-cache-components-adoption/SKILL.md
Popularity
- Repository stars
- 142,332
- Repository forks
- 32,047
- 7-day trend score
- 59
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/vercel/next.js/next-cache-components-adoption)