next-cache-components

Enable partial prerendering in Next.js 16+ routes with cache directives.

58|18|Updated May 22, 2020
One-click install
npx skills add https://github.com/gregrickaby/viewer-for-reddit --skill next-cache-components-gregrickaby
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: next-cache-components
Source: https://github.com/gregrickaby/viewer-for-reddit/tree/main/.agents/skills/next-cache-components
Command: npx skills add https://github.com/gregrickaby/viewer-for-reddit --skill next-cache-components-gregrickaby

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cache Components enable partial prerendering by blending static, cached, and dynamic content in Next.js routes.

Core Features & Use Cases

  • Partial Prerendering of routes with mixed content types
  • use cache directive, cacheLife, cacheTag, updateTag for fine-grained caching
  • Use case: speed up pages that render frequently changing data while keeping a fast static shell

Quick Start

Enable the feature by setting cacheComponents: true in your Next.js config and annotate data-fetching components with 'use cache' where data should be cached.

Frequently Asked Questions about next-cache-components

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

FAQPage Schema
How do I use cache components for partial prerendering in Next.js?

Cache components enable partial prerendering in Next.js by blending static and dynamic content. You enable the feature by setting cacheComponents: true in your Next.js config and annotate data-fetching components with the 'use cache' directive.

What is the 'use cache' directive in Next.js 16?

The 'use cache' directive is a Next.js 16 feature that enables partial prerendering by caching specific data-fetching components. It allows fine-grained caching control using cacheLife and cacheTag for robust invalidation across routes.

When should I use cache components instead of fully dynamic server rendering?

Use cache components when you have pages with a fast static shell but need to render frequently changing runtime data. This approach blends static, cached, and dynamic content to speed up rendering without sacrificing data freshness.

How do I invalidate cached data when using Next.js cache components?

You invalidate cached data in Next.js cache components using the cacheTag and updateTag directives. These provide robust, fine-grained cache invalidation alongside cacheLife controls for managing how long blended prerendered content persists.

Do I need Next.js 16 to use the cacheComponents feature?

Yes, the cacheComponents feature and the 'use cache' directive require a Next.js 16+ project. It relies on the framework's automatic key generation and partial prerendering capabilities introduced in that version.