next-cache-components

Implement Next.js 16 Cache Components with use cache, cacheLife, and cacheTag for partial prerendering.

Updated Jul 31, 2026
One-click install
npx skills add https://github.com/AarnavBaddam/skills --skill next-cache-components-aarnavbaddam
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: next-cache-components
Source: https://github.com/AarnavBaddam/skills/tree/main/next-cache-components
Command: npx skills add https://github.com/AarnavBaddam/skills --skill next-cache-components-aarnavbaddam

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Next.js 16 replaced experimental PPR and unstable_cache with a new Cache Components model, and developers need accurate guidance to configure caching, avoid runtime API errors inside cached scopes, and migrate legacy code without breaking their app. ## Core Features & Use Cases - Cache Components Setup: Enable cacheComponents in next.config and structure routes into static, cached, and dynamic (Suspense) content for Partial Prerendering. - Cache Control APIs: Apply the use cache directive at file, component, or function level, tune lifetimes with cacheLife(), tag entries with cacheTag(), and invalidate with updateTag() or revalidateTag(). - Migration Guidance: Convert unstable_cache, experimental.ppr, force-dynamic, and route-level revalidate config to the new directive-based model. - Use Case: A dashboard page renders a static shell instantly, serves hourly-cached stats via use cache with cacheTag('dashboard-stats'), and streams fresh user notifications through a Suspense boundary. ## Quick Start Ask the AI to convert an async data-fetching component in your Next.js app to use the 'use cache' directive with an appropriate cacheLife profile 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 shells, cached components with 'use cache', and dynamic content wrapped in Suspense.

How do I migrate from unstable_cache to use cache?

Replace the unstable_cache wrapper with an async function containing the 'use cache' directive. Move options.tags into cacheTag() calls, options.revalidate into cacheLife({ revalidate: N }), and drop the manual keyParts array since cache keys are generated automatically from arguments and closures.

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

Cached functions cannot access runtime request data like cookies(), headers(), or searchParams because the cached output must be request-independent. Extract the value outside the cached scope 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 the cache immediately so the same request sees fresh data, while revalidateTag triggers background revalidation with stale-while-revalidate behavior. Use updateTag after mutations where the response must reflect changes, and revalidateTag for non-urgent refreshes.

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

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