next-cache-components-optimizer

Drives Next.js routes to instant navigation using test-driven Cache Components optimization.

1|Updated Jan 24, 2026
One-click install
npx skills add https://github.com/Ech0xff/personal-site --skill next-cache-components-optimizer-ech0xff
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: next-cache-components-optimizer
Source: https://github.com/Ech0xff/personal-site/tree/main/.agents/skills/next-cache-components-optimizer
Command: npx skills add https://github.com/Ech0xff/personal-site --skill next-cache-components-optimizer-ech0xff

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @next/playwright, @playwright/test, next, and includes references (resource) components.

What problem does it solve? Next.js routes under Cache Components often block navigation on top-level awaits, coarse Suspense boundaries, or uncached data reads, leaving users staring at blank screens. This Skill sets up a repeatable, test-driven loop that encodes instant navigation as a failing @next/playwright instant() e2e test, works it to green, and ships the test as a permanent regression guard. ## Core Features & Use Cases - Test-driven optimization loop: Encode the goal as a failing instant() test (RED), push each Suspense boundary down to the data it guards, and verify GREEN on a production build, with a differential check proving the test measures the right property. - Fix pattern library: Before/after recipes for every blocker type — top-level awaits, cookies()/headers() reads, uncached fetches, searchParams, generateMetadata, non-deterministic values, and auth gates in layouts. - Rig discovery: A one-time per-repo setup that records how the project builds, exposes the testing API, authenticates the test user, and runs the e2e loop, so later runs skip rediscovery. - Use Case: A dashboard route waits on a charts query before anything paints. The Skill writes a locked instant() test, defers the query behind a Suspense boundary reusing the route's existing skeleton, and ships the passing test so the layout and skeletons now commit immediately while charts stream in. ## Quick Start Ask the agent to make a specific route's navigation instant using the next-cache-components-optimizer skill, naming the route and whether to guard soft navigation, initial load, or both.

Frequently Asked Questions about next-cache-components-optimizer

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

FAQPage Schema
How do I make a Next.js route navigation instant with Cache Components?

Encode the goal as a failing @next/playwright instant() test, then push each Suspense boundary down to the specific data read it guards while hoisting static layout UI into the shell. The route is done when the locked test passes green on a production build and a revert differential confirms the test measures the fix.

How to fix a Next.js route whose static shell is not prerendered?

Run a production build with --debug-prerender to get the full failing frame and the docs insight link for each blocker. Common causes are top-level awaits in layouts, cookies() or headers() reads, uncached fetches, and searchParams; each has a before/after recipe that moves the read behind a scoped Suspense boundary or into use cache.

Does this optimization work with older Next.js versions?

No, it requires Next.js 16.3 or later with cacheComponents: true in next.config, since without Cache Components there is no static shell to optimize. Upgrade first with npx @next/codemod upgrade, enable the flag, and resolve blocking routes before running the optimizer.

Why does my instant() test pass but the navigation still feels slow?

A green instant() test can be vacuous if the build lacks experimental.exposeTestingApiInProductionBuild, since the lock silently no-ops. It can also pass with an empty fallback that commits a blank shell; use the self-validating test variant and give every boundary a real loading skeleton.

What are the limitations of static shell optimization for URL-dependent routes?

When an entire page depends on params, searchParams, or the full URL, there may be no meaningful shared shell to grow, so pushing reads lower stops helping. For those routes, per-link prefetching with Link prefetch={true} under Partial Prefetching is the alternative, trading per-link server work for instant soft navigations.