next-cache-components

Implement Next.js 16 Cache Components with use cache, cacheLife, and cacheTag directives.

Updated Sep 10, 2026
One-click install
npx skills add https://github.com/sharad07072007/paras --skill next-cache-components-sharad07072007
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: next-cache-components
Source: https://github.com/sharad07072007/paras/tree/main/.agents/plugins/vercel/skills/next-cache-components/upstream
Command: npx skills add https://github.com/sharad07072007/paras --skill next-cache-components-sharad07072007

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Next.js 16 replaces legacy caching APIs like unstable_cache and route segment config with Cache Components, and developers need clear guidance on enabling Partial Prerendering, applying the use cache directive correctly, and handling cache invalidation without runtime errors. ## Core Features & Use Cases - Partial Prerendering Setup: Enable cacheComponents in next.config.ts and mix static, cached, and dynamic content in a single route using Suspense boundaries. - Cache Lifetime and Tagging: Configure cacheLife profiles (minutes, hours, days) and tag cached functions with cacheTag for targeted invalidation via updateTag or revalidateTag. - Migration Guidance: Convert legacy patterns like unstable_cache, force-dynamic, and revalidate exports to the use cache directive model. - Use Case: When building a dashboard page, keep the static shell prerendered, cache hourly stats with 'use cache' and cacheLife('hours'), and stream fresh user notifications through a Suspense boundary. ## Quick Start Enable Cache Components in my Next.js 16 app and refactor my page to use the use cache directive with cacheLife and cacheTag.

Frequently Asked Questions about next-cache-components

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enable Partial Prerendering in Next.js 16?

Set cacheComponents: true in next.config.ts to enable Cache Components, which replaces the old experimental.ppr flag. Routes can then mix static prerendered content, cached components with 'use cache', and dynamic content wrapped in Suspense.

How do I migrate from unstable_cache to use cache?

Replace unstable_cache wrappers with a function containing the 'use cache' directive. Move options.tags to cacheTag() calls and options.revalidate to cacheLife({ revalidate: N }); manual keyParts arrays are no longer needed because cache keys derive automatically from arguments and closures.

Why can't I use cookies() or headers() inside use cache?

Runtime APIs like cookies(), headers(), and searchParams are forbidden inside use cache because cached output must be request-independent. Extract the value outside the cached function and pass it as an argument, or use 'use cache: private' when compliance requirements prevent refactoring.

What is the difference between updateTag and revalidateTag in Next.js?

updateTag invalidates a cache tag immediately so the same request sees fresh data, while revalidateTag triggers background stale-while-revalidate so the next request gets updated content. Use updateTag after mutations needing instant consistency.

Does Next.js Cache Components work with Edge runtime or static export?

No, Cache Components require the Node.js runtime and a server; Edge runtime and static export are not supported. Non-deterministic values like Math.random() inside use cache also execute once at build time, so use connection() for request-time randomness.