next-cache-components

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Next.js 16 replaced legacy caching APIs like experimental.ppr, unstable_cache, and route segment config with a new Cache Components model, leaving developers unsure how to mix static, cached, and dynamic content in a single route. ## Core Features & Use Cases - Partial Prerendering Setup: Enable cacheComponents in next.config.ts and structure routes into static shells, cached components, and Suspense-wrapped dynamic content. - Cache Lifetime and Tagging: Apply the use cache directive with cacheLife profiles and cacheTag labels, then invalidate with updateTag or revalidateTag from Server Actions. - Migration Guidance: Convert unstable_cache calls, force-static/force-dynamic flags, and revalidate exports to the new directive-based API. - Use Case: A developer upgrading an e-commerce dashboard to Next.js 16 needs product data cached hourly with tag-based invalidation while user notifications stream in dynamically per request. ## Quick Start Show me how to enable Cache Components in Next.js 16 and cache my product list with hourly revalidation and tag-based invalidation.

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, and dynamic Suspense boundaries.

How to cache a function with the use cache directive in Next.js?

Add 'use cache' at the top of an async function, component, or file, then optionally call cacheLife for lifetime profiles and cacheTag for invalidation labels. Cache keys are generated automatically from arguments and closure variables.

How do I migrate unstable_cache to use cache in Next.js 16?

Replace the unstable_cache wrapper with a plain async function containing 'use cache', move options.tags into cacheTag() calls, and convert options.revalidate into cacheLife({ revalidate: N }). Manual keyParts arrays are no longer needed since keys derive from arguments.

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

Runtime APIs like cookies(), headers(), and searchParams are disallowed 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 in Next.js?

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 for read-your-writes scenarios in Server Actions.

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

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