mcpField
N
nextjs-cache-components-runtime

nextjs-cache-components-runtime

github.com/xirothedev开发254 次安装23 周前更新
代码仓库

关于 nextjs-cache-components-runtime

Next.js Cache Components Runtime 是处理 Next.js 16 缓存组件运行时问题的技能,适用于需要调整预渲染、流式传输、缓存、个性化或失效行为的开发者。它以明确缓存边界为核心,并提供按需加载的规则和示例。

主要功能

  1. 01指导 Cache Components 配置
  2. 02处理缓存边界与运行时渲染
  3. 03说明标签缓存及失效方法
  4. 04涵盖迁移和部署相关问题
  5. 05提供按需规则与代码示例

适用场景

  1. 01启用或排查 cacheComponents
  2. 02修复 Suspense 外未缓存数据错误
  3. 03迁移旧式路由缓存配置
  4. 04设计自托管或无服务器缓存行为

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/xirothedev/skills --skill nextjs-cache-components-runtime

安装后在 Claude Code 中输入/nextjs-cache-components-runtime确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

AGENTS.md
metadata.json
test-cases.json
dataset/cache/metadata-runtime/
correct.ts
incorrect.ts
notes.md
dataset/cache/migration-segment-configs/
correct.tsx
incorrect.tsx
notes.md
dataset/cache/remote-cache/
correct.ts
incorrect.ts
notes.md
dataset/cache/runtime-suspense/
correct.tsx
incorrect.tsx
notes.md
dataset/cache/tag-invalidation/
correct.ts
incorrect.ts
notes.md
dataset/cache/use-cache-scope/
correct.tsx
incorrect.tsx
notes.md
references/
_sections.md
cache-metadata-runtime.md
cache-migration-segment-configs.md
cache-remote-cache.md
cache-runtime-suspense.md
cache-tag-invalidation.md
cache-use-cache-scope.md
sources/
inventory.json

详细介绍

Next.js Cache Components 运行时

当任务会改变 Next.js 路由的预渲染、流式传输、缓存、个性化或失效方式时,请使用此技能。明确标示缓存边界,不要依赖旧版路由级动态/静态标记。

适用场景

以下情况请使用此技能:

  • 启用或调试 cacheComponents: true
  • 添加 use cache、cacheLife、cacheTag、updateTag 或 revalidateTag
  • 修复“未缓存的数据位于 Suspense 外部”这类构建/运行时错误
  • 将 cookies()、headers()、params 或 searchParams 等运行时 API 传递给缓存函数
  • 将 dynamic、revalidate 或旧版缓存代码迁移至 Cache Components
  • 为可自托管或无服务器部署设计缓存行为

按需加载

从此文件开始。仅在任务需要时加载详细文件:

references/_sections.md
references/cache-use-cache-scope.md
references/cache-runtime-suspense.md
references/cache-tag-invalidation.md
references/cache-remote-cache.md
references/cache-metadata-runtime.md
references/cache-migration-segment-configs.md
dataset/cache/use-cache-scope/correct.tsx
sources/inventory.json

每个规则文件都包含:

  • 该模式的重要性
  • 错误与正确示例
  • 包含更大型 TypeScript/TSX 示例的数据集路径
  • 官方来源参考

按优先级划分的规则类别

优先级类别影响前缀
1缓存边界严重cache-
2数据与运行时渲染高data-
3运维与部署高ops-

来源政策

Cache Components 相关内容请使用 Next.js 16 官方文档。除非项目尚未启用 cacheComponents,否则不要依赖 Next.js 13/14/15 的缓存建议。

评论

支持 Markdown