next-cache-components

Configure Next.js Cache Components with cacheComponents and use cache directives.

Updated Apr 11, 2026
One-click install
npx skills add https://github.com/BrunoAlpezdev/lluvia-de-ideas --skill next-cache-components-brunoalpezdev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: next-cache-components
Source: https://github.com/BrunoAlpezdev/lluvia-de-ideas/tree/main/.agents/skills/next-cache-components
Command: npx skills add https://github.com/BrunoAlpezdev/lluvia-de-ideas --skill next-cache-components-brunoalpezdev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps you improve performance in Next.js by letting you mix static, cached, and dynamic output within the same route, without relying on older experimental PPR options.

Core Features & Use Cases

  • Enables Cache Components (Next.js 16+): Turn on cacheComponents: true to replace legacy experimental.ppr and unlock Partial Prerendering behavior.
  • Controls output freshness with use cache: Cache async data using the use cache directive at file, component, or function level for fast repeat visits.
  • Manages cache lifecycle and invalidation: Use cacheLife() for staleness/revalidation/expiry control and cacheTag() with updateTag()/revalidateTag() for targeted cache invalidation.
  • Handles runtime constraints: Prevent forbidden runtime API usage (like cookies(), headers(), searchParams) inside use cache, with an escape hatch via use cache: private.
  • Choose correct rendering strategy per data type: Combine auto-prerendered static segments, cached segments, and streamed dynamic segments via Suspense.

Quick Start

Enable Cache Components by setting cacheComponents: true in your next.config.ts, then mark your async data functions with the use cache directive and tune their behavior using 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 combine static prerendered output with dynamic rendering in Next.js routes?

Mix static, cached, and dynamic Next.js output by enabling `cacheComponents: true`, marking async functions with `use cache`, and streaming fresh runtime segments via Suspense boundaries.

What is the `use cache` directive in Next.js and when should I use it?

The `use cache` directive in Next.js caches async data at the file, component, or function level to deliver fast repeat visits. Use it for server-side data that must remain static between requests.

How do I enable Partial Prerendering in Next.js 16+?

Enable Partial Prerendering in Next.js 16+ by setting `cacheComponents: true` in your `next.config.ts` file, which replaces the legacy `experimental.ppr` option and unlocks the feature.

How do I control cache invalidation and staleness for Next.js Cache Components?

Control cache invalidation in Next.js by applying `cacheLife()` for staleness and expiry management, and assign `cacheTag()` labels to use with `revalidateTag()` for targeted cache invalidation.

Why does `use cache` break when I call cookies() or headers() inside it?

Calling `cookies()`, `headers()`, or `searchParams` inside `use cache` breaks because runtime APIs are forbidden within cached segments. Use the `use cache: private` escape hatch instead.

Can I use Cache Components for partial prerendering without experimental PPR?

Yes, you can use Cache Components for partial prerendering without legacy experimental PPR by enabling `cacheComponents: true` in your `next.config.ts` to unlock the modern behavior.