cache-components

Guide Next.js cacheComponents workflows for static and dynamic boundaries.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cache Components enable co-located caching and streaming in Next.js apps, turning heavy, repeated data fetching into fast static shells with dynamic content flowing in via Suspense.

Core Features & Use Cases

  • Co-located data caching with 'use cache' to produce static shells plus streaming content
  • Granular invalidation using cacheTag(), updateTag(), and revalidateTag() for precise data freshness
  • Flexible cache lifetimes via cacheLife() to distinguish static vs dynamic content
  • Subshell and generateStaticParams workflows for reusable route shells and progressive rendering
  • Proactive project automation: automatic activation when cacheComponents: true is detected
  • Suspense boundaries to stream uncached or dynamic data

Quick Start

Enable Cache Components in a Next.js project by turning on cacheComponents: true in next.config and begin annotating components with 'use cache', cacheLife(), and related APIs to leverage static shells and streaming content.

Frequently Asked Questions about cache-components

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use cache components in Next.js to create static shells with streaming content?

Next.js cache components use co-located 'use cache' directives to generate static shells, streaming dynamic data via Suspense boundaries. You annotate components to separate cached regions from dynamic content, producing fast initial page loads with asynchronous data flows.

What is the best way to invalidate cached data in Next.js using cacheTag and revalidateTag?

For granular data invalidation in Next.js cache components, apply cacheTag() to mark cached regions, then call updateTag() or revalidateTag() to refresh specific data. This ensures precise freshness control without invalidating the entire static shell.

Does Next.js cache components work with generateStaticParams for progressive rendering?

Yes, Next.js cache components support generateStaticParams workflows for progressive rendering. This allows reusable route shells to pre-render static content while dynamic regions stream in, enabling multi-tenant subshells and correct static versus dynamic boundaries.

How do I control cache lifetimes for static versus dynamic content in Next.js?

You control cache lifetimes in Next.js cache components using the cacheLife() function. It distinguishes static from dynamic content by setting flexible expiration policies, ensuring cached regions maintain appropriate freshness levels based on data requirements.

Why do I need cacheComponents set to true in next.config to use 'use cache' directives?

Setting cacheComponents: true in next.config enables the cache components feature, proactively activating the guidance for 'use cache' directives. This ensures strict async placement and proper handling of cacheLife() and cacheTag() APIs across your project.

When should I use Suspense boundaries with Next.js cache components for dynamic data?

Use Suspense boundaries in Next.js cache components to stream uncached or dynamic data. They wrap dynamic regions, allowing the static shell to render immediately while asynchronous data loads flow in progressively without blocking the UI.