next-cache-components

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

Updated Mar 29, 2026
One-click install
npx skills add https://github.com/Divith123/Flamingo --skill next-cache-components-divith123
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: next-cache-components
Source: https://github.com/Divith123/Flamingo/tree/main/.agents/skills/next-cache-components
Command: npx skills add https://github.com/Divith123/Flamingo --skill next-cache-components-divith123

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 clear guidance on mixing static, cached, and dynamic content in a single route without misusing runtime APIs. ## Core Features & Use Cases - Partial Prerendering Setup: Enable cacheComponents in next.config.ts and structure pages with static shells, cached components, and Suspense-wrapped dynamic content. - Cache Control APIs: Apply the use cache directive at file, component, or function level with cacheLife profiles and cacheTag-based invalidation via updateTag and revalidateTag. - Migration Guidance: Convert legacy patterns like experimental.ppr, force-dynamic, revalidate exports, and unstable_cache to the new directive model. - Use Case: When building a dashboard that needs an instant static shell, hourly-refreshed stats, and live user notifications, this Skill shows exactly how to combine all three content types in one route. ## Quick Start Show me how to enable Cache Components in my Next.js 16 app and refactor my dashboard page to use the use cache directive with proper 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. Once enabled, routes can mix static prerendered content, cached components, and dynamic Suspense boundaries.

How to use the use cache directive in Next.js?▼

Add 'use cache' at the top of a file, component, or async function to cache its output. Control lifetime with cacheLife() using built-in profiles like 'hours' or inline stale, revalidate, and expire values, and tag entries with cacheTag() for invalidation.

How do I migrate from unstable_cache to use cache?▼

Replace the unstable_cache wrapper with an 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 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 cannot depend on per-request data. Extract the value outside the cached function 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 that must be visible instantly, such as updating a product record.

What are the limitations of Next.js Cache Components?▼

Cache Components require the Node.js runtime and do not support Edge runtime or static export. Non-deterministic values like Math.random() and Date.now() execute once at build time inside use cache, so request-time randomness needs connection() from next/server.