next-cache-components

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

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/rub803030/examenprograma --skill next-cache-components-rub803030
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: next-cache-components
Source: https://github.com/rub803030/examenprograma/tree/main/EXAMEN_PROGRA_2-master/.agents/skills/next-cache-components
Command: npx skills add https://github.com/rub803030/examenprograma --skill next-cache-components-rub803030

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Next.js 16 replaces legacy caching APIs like experimental.ppr, 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 Control APIs: Apply the use cache directive at file, component, or function level, and tune lifetimes with cacheLife profiles and cacheTag labeling. - Cache Invalidation: Use updateTag for immediate same-request invalidation and revalidateTag for stale-while-revalidate behavior in Server Actions. - Use Case: Migrate a dashboard page from unstable_cache to use cache by replacing manual key arrays with automatic cache keys, moving tags into cacheTag calls, and converting revalidate options into cacheLife configuration. ## Quick Start Enable cacheComponents in my Next.js 16 config and refactor this 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, and dynamic Suspense boundaries.

How to migrate from unstable_cache to use cache in Next.js?▼

Replace the unstable_cache wrapper with a function containing the 'use cache' directive. Move options.tags into cacheTag() calls, convert options.revalidate into cacheLife({ revalidate: N }), and remove manual key arrays since cache keys generate 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 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 stale-while-revalidate so the next request gets updated content. Both are called from Server Actions after a data mutation.

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 only once at build time.