Skip to content
Back to skills

Nextjs Knowledge Patch

ASecurity

Next.js

  • 25 stars
  • 0 votes
  • 0 copies
  • 6 views
  • Added September 5, 2026
developmenttypescriptshellreactnextjsnodedockerdebugginggitapisecurity

Works with

  • cli
  • api
  • mcp

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 9 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill nextjs-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Nextjs Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Nextjs Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-nextjs-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-nextjs-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: nextjs-knowledge-patch
description: Next.js
version: "16.4.6"
license: MIT
metadata:
  author: Nevaberry
---


# Next.js Knowledge Patch

Load this skill when upgrading Next.js projects or working on caching,
navigation, Turbopack, image optimization, deployment, or development tooling.
Use the topic references for complete guidance, examples, and version-specific
behavior.

## Reference index

| Reference | Topics |
| --- | --- |
| [Migration and Runtime](references/migration-and-runtime.md) | Security upgrades, removed APIs, upgrade workflows, request handling, tainting |
| [Caching and Prefetching](references/caching-and-prefetching.md) | Cache Components, cache keys, storage, invalidation, prefetch stages, ISR shells |
| [Routing and Rendering](references/routing-and-rendering.md) | Route matching, metadata, Instant Insights, offline recovery, navigation, error boundaries |
| [Bundlers and Builds](references/bundlers-and-builds.md) | Turbopack, loaders, caching, Rspack, adapters, build output |
| [Images, CSS, and Assets](references/images-css-and-assets.md) | Image allowlists, optimizer options, AVIF, metadata images, icons, CSS |
| [Tooling and Observability](references/tooling-and-observability.md) | Logs, debugging, analyzer, browser inspection, Playwright, MCP, agent documentation |
| [Types and Configuration](references/types-and-configuration.md) | TypeScript, browsers, linting, canary flags, script integrity, CSP |

## Breaking changes and deprecations

### Cache Components configuration

Replace `experimental.dynamicIO` and `experimental.ppr` with top-level
`cacheComponents: true`. Remove route-level `export const experimental_ppr`
declarations. `create-next-app` enables Cache Components by default; use its
Cache Components setup prompt to opt out.

### Lint scripts and removed configuration

`next lint` warns in 15.5 and is removed in 16. The codemod updates
`package.json` scripts to call ESLint directly and installs required dependencies:

```sh
npx @next/codemod@latest next-lint-to-eslint-cli .
```

Next.js 16.0 removes `unstable_rootParams()`. Remove `appIsrStatus`,
`buildActivity`, and `buildActivityPosition` from `devIndicators`.
Remove `experimental.appNewScrollHandler` when upgrading to 16.4.
Remove `experimental.viewTransition` when upgrading to `16.4.0-canary.13`,
where that flag has already been removed.

React 18 support is deprecated for the Pages Router; plan to upgrade those
projects to React 19. `@next/eslint-plugin-next` defaults to ESLint Flat Config,
and `eslint-config-next` supports ESLint 10.

### Route matching and asynchronous image inputs

Strict route matching is enabled by default. Give intercepted routes a canonical
route, check for incompatible parallel route slots, and fix App Router pages
that fail to match a route.

Await `params` in metadata image handlers. When `generateImageMetadata` defines
image variants, the handler also receives `id` as a `Promise<string>`.

### Image configuration changes

In 16, the default `images.qualities` allowlist is `[75]`; set an explicit
allowlist for other quality values. `next/image` maps `quality` to the closest
allowed value. For local image queries, `images.localPatterns` can use `search`
for an exact query, omit it for any query, or use `''` for no query strings.

The default `images.minimumCacheTTL` rises from 60 to 14,400 seconds, and
`images.imageSizes` drops the 16-pixel width. The optimizer blocks local IP
addresses by default and follows up to three redirects. Set
`images.maximumRedirects` to `0` to stop redirects, or enable
`images.dangerouslyAllowLocalIP` when intentionally optimizing private-network images.

### Security upgrades

Upgrade to `next@15.5.29` on the 15.5 line or `next@16.4.5` on the 16.4 line for
fixes affecting self-hosted response forwarding, SVG rejection in Image
Optimization, and HttpOnly cookies on Edge routes. The 16.4.5 release also fixes
cache disclosure or poisoning involving `unstable_cache`, shared fallback shells,
and binary arguments, and includes a follow-up fix for nested `'use cache'`
calls across root parameter values.

The migration reference preserves the other security upgrade targets and the
Windows vulnerability conditions. The image reference covers AVIF's temporary
disablement and restoration: 15.5.25 can produce AVIF again when a newer `sharp`
is installed.

## Cache Components quick reference

### Boundaries, keys, and inputs

Layouts and pages are separate cache entry points: place `'use cache'` at the
top of both `layout.tsx` and `page.tsx` to cache both. Keys include build and
function IDs, serialized props or arguments, and captured enclosing-scope values.

Read `cookies()`, `headers()`, and `searchParams` outside the cached scope and
pass resolved values as arguments. Each boundary has its own `React.cache`
scope, so pass values from the caller's `React.cache` explicitly.

Cached components can return JSX and forward JSX slots or Server Actions as
opaque props. Forward slots without inspecting them and pass actions to the
rendered form without invoking them inside the cached scope to keep these
inputs out of the key.

Async accessors from `next/root-params` correspond to dynamic segments above the
root layout; Server Components can call them inside `'use cache'` scopes too.
Files with a top-level `'use cache'` can export literal constants alongside
cached functions.

### Lifetime, storage, and invalidation

The default `cacheLife` profile has a five-minute client stale time, a 15-minute
server revalidation interval, and no time-based expiration. The client router
enforces a 30-second minimum stale time even for shorter profile values.

Runtime storage defaults to memory; serverless requests may miss entries from
another instance. Use `cacheMaxMemorySize` to size it or configure `cacheHandlers`
for custom storage. Import handler types from `next/cache-handlers`.

Call `cacheTag` after fetching when tags depend on results. `revalidateTag()`
accepts a built-in or custom `cacheLife` profile name or inline expiration:

```ts
import { revalidateTag } from 'next/cache'

revalidateTag('products', { expire: 3600 })
```

Tag revalidation discards matching entries that predate it; completed entries
created afterward can be reused. Server Action revalidation provides strong
consistency for invalidated entries. A Route Handler can revalidate and then
redirect in the same request.

### Cache constraints and diagnostics

Static export does not support `'use cache'`; use a Node.js server, Docker, or
an adapter supporting the directive. Awaiting a promise for runtime or uncached
data from outside a cached scope can cause a 50-second prerender timeout,
including promises from closures or shared maps. Resolve request data in the
caller and pass serializable values.

Proxy ignores `cache`, `next.revalidate`, and `next.tags` on `fetch()`.
Set `NEXT_PRIVATE_DEBUG_CACHE=1` when starting a development or production
server for verbose cache logs, including ISR logs.

## Prefetching and rendering quick reference

### Shared shells and render stages

In production, Partial Prefetching fetches one reusable shell per route pattern
for viewport links and caches it for the session:

```ts
export default { cacheComponents: true, partialPrefetching: true }
```

With Partial Prefetching enabled, `<Link prefetch={true}>` extends prefetching
to synchronous or `'use cache'` content available at build time. Add
`export const prefetch = 'allow-runtime'` on the route to include request-time
cached content too.

Use stable `prefetch()` to defer content beyond the shared shell and
`navigation()` to defer it until navigation. Instant Insights checks both calls.
Set `ensureStatic` to `'shell'`, `'prefetch'`, or `'navigation'` to choose which
stage Next.js verifies as static.

### Inspect instant navigation

The 16.3 Preview reports blocking navigations as development errors with Cache
Components enabled. Stream slow subtrees behind `<Suspense>`, cache eligible
work with `'use cache'`, or allow blocking with `export const instant = false`
in the page or layout.

Wrap a link click and shell assertions in `instant()` from `@next/playwright`;
assert streamed content after the callback returns. The Navigation Inspector
can pause at the shell and resume to the completed page. In the preview, reading
route params in a partially prefetched shell can block without an Instant
Insight; check that case with the inspector or `instant()`.

## Build and tooling quick reference

### Turbopack and TypeScript

Move `experimental.turbo` settings to top-level `turbopack`; the old key remains
supported through 15.x. The Turbopack filesystem cache is enabled by default
for development and builds. Restore the generated `.next` directory between
CI runs to reuse the build cache. Development memory eviction is enabled by default.

Turbopack enables Babel when it finds a Babel configuration. It can externalize
transitive packages listed in `serverExternalPackages`; you can remove direct
dependency declarations added solely to make externalization work.

Upgrade the local `typescript` dependency to use TypeScript 7 during `next build`:

```sh
pnpm add -D typescript@^7
```

### Analyzer, debugging, and upgrades

Run `next analyze` for the Turbopack bundle analyzer. Each run records a snapshot
for comparison, and the analyzer can export a versioned bundle graph as JSON Lines.
Use `next build --debug-prerender` for prerender failures,
`NEXT_CPU_PROF=1 next dev` for CPU traces, `next dev --inspect` for the application
process inspector, or `next start --inspect` for production server debugging.

Starting in 16.1, use `next upgrade` for subsequent upgrades. `next upgrade --ai`
supports agent-assisted upgrades, defaults to a separate worktree when Git is
available, can skip React and ESLint upgrades, and prefers the declared package manager.

### Agent documentation and compilation diagnostics

`create-next-app` generates `AGENTS.md` pointing to bundled Markdown docs at
`node_modules/next/dist/docs/`. When `next dev` detects a coding agent and managed
markers are absent, it adds the pointer; top-level `agentRules: false` disables generation.

Use DevTools MCP `get_routes` to list routes, `get_compilation_issues` for
project-wide diagnostics, or `compile_route` for one route. Compilation
diagnostics are available through the running dev server's `/_next/mcp` endpoint;
an agent client can connect by adding `next-devtools-mcp` to `.mcp.json`.

Files in this skill

  • SKILL.md8.6 KB
  • coverage.json1.3 KB
  • references/bundlers-and-builds.md5.7 KB
  • references/caching-and-prefetching.md5.6 KB
  • references/images-css-and-assets.md2.8 KB
  • references/migration-and-runtime.md3.3 KB
  • references/routing-and-rendering.md5.1 KB
  • references/tooling-and-observability.md4.7 KB
  • references/types-and-configuration.md2.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.