next-cache-components

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

Updated Aug 21, 2025
One-click install
npx skills add https://github.com/Adithiya-S/AI-Study-Companion --skill next-cache-components-adithiya-s
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: next-cache-components
Source: https://github.com/Adithiya-S/AI-Study-Companion/tree/main/.agents/skills/next-cache-components/upstream
Command: npx skills add https://github.com/Adithiya-S/AI-Study-Companion --skill next-cache-components-adithiya-s

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, and handling cache invalidation correctly. ## 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 Control: Configure cacheLife with built-in profiles (minutes, hours, days) or inline stale/revalidate/expire values, and tag entries with cacheTag for targeted invalidation via updateTag or revalidateTag. - Migration Guidance: Convert legacy patterns like experimental.ppr, force-static, revalidate exports, and unstable_cache calls into the use cache directive model. - Use Case: When building a dashboard that mixes a static shell, hourly-refreshed stats, and per-user notifications, apply use cache with cacheLife('hours') to the stats component and wrap the dynamic notifications in Suspense. ## Quick Start Ask the AI to refactor a Next.js page to use Cache Components with the use cache directive, cacheLife, and cacheTag for cached data and Suspense for dynamic content.

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 and Partial Prerendering. This replaces the old experimental.ppr flag and lets you mix static, cached, and dynamic content in one route.

How do I migrate from unstable_cache to use cache?

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

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

Runtime APIs like cookies(), headers(), and searchParams are not allowed inside use cache because cached output must be request-independent. Extract the value outside and pass it as an argument, or use 'use cache: private' for compliance cases.

What is the difference between updateTag and revalidateTag?

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

Does Cache Components work with Edge runtime or static export?

No, Cache Components requires the Node.js runtime and does not support Edge runtime or static export. Non-deterministic values like Math.random() inside use cache also execute once at build time.