Skip to content
Back to skills

Nextjs Knowledge Patch

ASecurity

Next.js

  • 25 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added May 27, 2026
developmenttypescriptshellreactnextjsnodedockerdebugginggitapisecurity

Works with

  • terminal
  • cli
  • api
  • mcp

Security analysis

A100/100

Pro scans all 3 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/badge)](https://www.skillsdirectory.com/skills/nevaberry-nextjs-knowledge-patch)

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 or working on its caching, routing,
rendering, bundlers, images, configuration, or development tools.
Use the topic references for complete examples and version-specific behavior.

## Reference index

| Reference | Topics |
| --- | --- |
| [Migration and runtime](references/migration-and-runtime.md) | Security fixes, upgrades, codemods, request behavior, offline recovery |
| [Types and configuration](references/types-and-configuration.md) | TypeScript, browser minimums, ESLint, Biome, preview flags |
| [Caching and prefetching](references/caching-and-prefetching.md) | Cache Components, cache keys, lifetime, invalidation, navigation stages |
| [Routing and rendering](references/routing-and-rendering.md) | Route matching, root params, loading shells, boundaries, scroll, transitions |
| [Images, CSS, and assets](references/images-css-and-assets.md) | Image defaults, metadata images, AVIF, PostCSS, Lightning CSS, CSP |
| [Bundlers and builds](references/bundlers-and-builds.md) | Turbopack, loaders, caches, Rspack, adapters, exports |
| [Tooling and observability](references/tooling-and-observability.md) | Diagnostics, profiling, analyzer, documentation, agent workflows, MCP |

## Breaking changes and deprecations

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

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

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

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.

Next.js 16.0 removes `unstable_rootParams()`. For root parameter accessors,
see the routing reference. React 18 support is deprecated for the Pages Router;
plan to upgrade Pages Router projects to React 19.

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.

## Security upgrade guidance

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.

For Windows filesystem deployments using both routers with Cache Components
disabled, upgrading is the only documented fix for CVE-2026-75604.
The migration reference preserves the other security fixes and their upgrade targets.

## Image migration checks

In 16, `images.qualities` defaults to `[75]`; set an explicit allowlist to keep
using other quality values. `next/image` maps `quality` to the closest allowed value.

For local image URLs, `images.localPatterns` can set `search` to allow an exact
query, omit it to allow any query, or set it to `''` to allow only URLs without
query strings. Local query strings warn in 15.5 when `images.localPatterns` is unset.

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

Await metadata image handler `params`; with variants from `generateImageMetadata`,
the handler also receives `id` as a `Promise<string>`.

## Cache Components boundaries

- Layouts and pages are separate cache entry points: put `'use cache'` at the
  top of both files to cache both.
- Keys include build and function IDs, serialized props or arguments, and
  captured values from the enclosing scope.
- Forward JSX slots without inspecting them and pass Server Actions to the
  rendered form without invoking them inside the cached scope to keep these
  opaque inputs out of the key. Cached components can return JSX.
- Read `cookies()`, `headers()`, and `searchParams` outside the cached scope,
  then pass resolved values as arguments. Each boundary has its own
  `React.cache` scope; pass values from the caller's scope explicitly.
- Awaiting runtime or uncached promises 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.
- A file with top-level `'use cache'` can export literal constants alongside
  cached functions.
- Static export does not support `'use cache'`; use a Node.js server, Docker,
  or an adapter that supports the directive.

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 when the profile specifies less.

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

## Cache invalidation and diagnostics

Call `cacheTag` after fetching when tags depend on the result.
`revalidateTag()` accepts an inline expiration in seconds or a built-in or custom
`cacheLife` profile name as its second argument:

```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.

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

## Prefetching and rendering stages

Enable Partial Prefetching alongside Cache Components:

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

In production it fetches one reusable shell per route pattern for viewport
links and caches it for the session. With Partial Prefetching enabled,
`<Link prefetch={true}>` extends prefetching to synchronous or `'use cache'`
content available at build time. Set `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. The stable exports drop the
`unstable_` prefix, and Instant Insights checks both calls.
Set `ensureStatic` to `'shell'`, `'prefetch'`, or `'navigation'` to choose
which stage Next.js verifies as static.

In the 16.3 Preview, blocking navigation produces development errors with
Cache Components enabled. Stream the slow subtree behind `<Suspense>`, cache
eligible work with `'use cache'`, or set `export const instant = false`
in the page or layout to allow blocking.

Use `instant()` from `@next/playwright` around the link click and shell
assertions to check what appears without waiting for the network. Assert
streamed content after the callback returns. The Navigation Inspector can
pause a navigation at its shell; **Resume** reveals the completed page.
In the preview, reading route params in a partially prefetched shell can block
without an Instant Insight, so check that case with the inspector or `instant()`.

## Routing and error recovery

Import async accessors from `next/root-params` for dynamic segments above the
root layout. Server Components can call them inside `'use cache'` scopes too.

Import stable `catchError` from `next/error`; the fallback's `ErrorInfo`
provides `retry()` to refetch the boundary's children. See the routing reference
for the earlier `unstable_catchError` and `error.tsx` retry APIs.

With Instant Navigations enabled, a URL omitted from `generateStaticParams`
can serve its loading shell on its first visit while prerendering runs in the
background. Later visitors get completed content from the cache.

If the site sets `scroll-behavior: smooth`, add `data-scroll-behavior="smooth"`
to the root `<html>` to opt in to navigation smooth-scroll handling.

## Bundlers and build configuration

Move `experimental.turbo` settings to top-level `turbopack` in `next.config.ts`;
the old key remains supported through 15.x. Turbopack enables Babel automatically
when it finds a Babel configuration file.

The Turbopack filesystem cache is enabled by default for development and builds.
For the experimental production-cache opt-in, set
`experimental.turbopackFileSystemCacheForBuild: true`; restore the generated
`.next` directory between CI runs to reuse the cache. See the build reference
for the version-specific defaults and opt-in.

Turbopack supports `import.meta.glob()` with async loaders by default and
`{ eager: true }` for immediate imports. Use `type: 'text'` in rules for string
imports, or `false` in `turbopack.resolveAlias` to ignore matching module requests.

`next dev` and `next build` use separate output directories and can run
concurrently. A lock prevents multiple instances of the same command in the project.

## Development and upgrade tools

Use `next analyze` for the Turbopack bundle analyzer; runs record snapshots for
comparison and 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 inspector
in the application-code process, or `next start --inspect` for production debugging.

Browser errors appear in the development terminal by default. Configure
`logging.browserToTerminal` as `'warn'` for warnings and errors, `true` for all
console output, or `false` to disable forwarding.

Use `next upgrade` for subsequent upgrades starting in 16.1.
`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 project's declared package manager.

For bundled documentation, generated agent rules, browser inspection,
DevTools MCP route discovery and compilation diagnostics, use the tooling reference.

Files in this skill

  • SKILL.md6.4 KB
  • references/caching.md3.7 KB
  • references/migration-guide.md5.4 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.