nextjs-app-router

Implements Next.js 16 App Router patterns for routing, caching, streaming, and Server Actions.

Updated Aug 2, 2026
One-click install
npx skills add https://github.com/leonardoacosta/skills --skill nextjs-app-router-leonardoacosta
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs-app-router
Source: https://github.com/leonardoacosta/skills/tree/main/web-frontend-kit/skills/nextjs-app-router
Command: npx skills add https://github.com/leonardoacosta/skills --skill nextjs-app-router-leonardoacosta

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Next.js 16 changed the caching model, renamed middleware to proxy.ts, and introduced Cache Components and Instant Navigations, leaving developers unsure how to fetch data, invalidate caches, and structure routes correctly. This Skill provides the decision trees, code patterns, and gotchas needed to build and debug App Router applications without stale-data surprises. ## Core Features & Use Cases - Data Fetching & Caching Model: Explains the dynamic-by-default behavior, the 'use cache' directive, cacheTag/revalidateTag invalidation, and a stale-data triage flowchart for diagnosing over-cached or under-cached routes. - Streaming, Suspense & Instant Navigations: Covers parallel fetches with Promise.all, Suspense boundaries, partial prefetching, and the instant = false opt-out for routes that must block on fresh data. - Server Actions, Auth & Route Organization: Provides validated Server Action patterns with Zod, proxy.ts bulk route protection, layout-level auth checks, and route group/intercepting route conventions. - Use Case: A page shows stale product data after a mutation. Follow the stale-data triage tree to find the 'use cache' function missing a cacheTag, add the tag, and call revalidateTag from the Server Action. ## Quick Start Ask the agent to review your Next.js app route for caching and data-fetching issues using the nextjs-app-router patterns, for example: diagnose why my /products page serves stale data after a mutation.

Frequently Asked Questions about nextjs-app-router

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

FAQPage Schema
How do I fix stale data in a Next.js 16 App Router page?

Next.js 16 is dynamic by default, so stale data means something explicitly opted into caching. Check for fetch calls with next.revalidate, or a 'use cache' directive on the route or a called function, then invalidate with revalidateTag or revalidatePath after mutations.

How do Server Actions work with validation in Next.js?

Place 'use server' at the top of a file and validate all input with Zod safeParse before touching the database, since clients can send anything. Return an error object for handled failures and call revalidatePath or revalidateTag after the mutation.

What is the difference between revalidatePath and revalidateTag?

revalidatePath re-renders an entire route segment, while revalidateTag invalidates specific tagged cache entries across multiple routes. Use tags when the same data appears on more than one route, since they are cheaper and more targeted.

Does Next.js 16 still use middleware.ts for route protection?

No, middleware.ts was renamed to proxy.ts in Next.js 16, including the exported function name, though the logic is identical. Use it for bulk route protection at the edge, and use layout-level auth() checks for per-route role logic.

Why is my Next.js page not rendering server-side HTML?

A 'use client' layout that gates children behind client-only state never renders the subtree server-side, so raw SSR HTML contains only the fallback. Make the layout a server component and resolve gating data from cookies or headers in the RSC.

When should I use React cache() versus 'use cache' in Next.js?

React cache() only deduplicates identical fetches within a single request and does not persist across requests. For cross-request caching of DB queries or components, wrap the function in 'use cache' with a cacheTag so Server Actions can invalidate it.