next-cache-components

Enable Next.js 16+ Partial Prerendering via cacheComponents and use cache directives.

146|12|Updated Jan 30, 2025
One-click install
npx skills add https://github.com/zoonk/zoonk --skill next-cache-components-zoonk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: next-cache-components
Source: https://github.com/zoonk/zoonk/tree/main/.agents/skills/next-cache-components
Command: npx skills add https://github.com/zoonk/zoonk --skill next-cache-components-zoonk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Next.js projects often struggle to balance fast initial loads with fresh dynamic data. Cache Components provide a structured way to mix static, cached, and dynamic content via the cacheComponents feature, enabling partial prerendering to improve performance without sacrificing up-to-date information.

Core Features & Use Cases

  • Enable Cache Components in Next.js 16+ by setting cacheComponents: true in next.config.ts.
  • Use the "use cache" directive to mark page components and functions for caching with customizable cacheLife, cacheTag, and updateTag.
  • Real-world use cases include dashboards, product catalogs, and profile pages where static shells combine with periodically refreshed data.

Quick Start

Enable cache components in next.config.ts and annotate your components with the use cache directive to start caching with a default policy.

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 for static and dynamic content in Next.js?

Partial prerendering in Next.js is enabled by setting cacheComponents: true in next.config.ts. This allows routes to mix static, cached, and dynamic content, optimizing rendering for pages with varying data refresh cycles.

What is the Next.js cacheComponents feature used for?

The cacheComponents feature is used for partial prerendering to balance fast initial loads with fresh dynamic data. It provides a structured way to cache page components, improving web performance without sacrificing up-to-date information.

How do I cache specific page components using Next.js cache directives?

You can cache specific page components by annotating them with the use cache directive. This enables caching with customizable policies using cacheLife, cacheTag, and updateTag directives to control data refresh cycles.

Does the Next.js cacheComponents feature require a specific version?

Yes, the cacheComponents feature requires Next.js 16 or higher. You must enable it within next.config.ts and use supported cache directives to manage static, cached, and dynamic content rendering.

When should I use Next.js cache components for web performance optimization?

Use cache components for web performance optimization on routes like dashboards, product catalogs, and profile pages. It is ideal when static shells combine with periodically refreshed data to balance load speed and dynamic content.