--- name: next-best-practices description: Next.js App Router best practices covering file conventions, RSC boundaries, async APIs, data patterns, hydration errors, metadata, route handlers, image/font optimization, and bundling. Use when writing or reviewing Next.js code to prevent hydration errors, RSC violations, data waterfalls, and configuration mistakes. --- # Next.js review and implementation Read the installed `next` version and relevant `node_modules/next/dist/docs/` pages before changing framework behavior. Those docs and project configuration take precedence; use a matching online version/source tag when local docs are unavailable. The original vercel-labs/next-skills content was removed upstream on 2026-06-17; workflow skills now live in vercel/next.js `skills/`. Docs are bundled from 16.2; in a monorepo, read the app's own `next` package. The nextjs.org links in these files have local equivalents with numbered folders, so search by file name (`find node_modules/next/dist/docs -name proxy.md`). `01-app/02-guides/upgrading/version-16.md` lists the breaking changes. Per-error pages (`/docs/messages/*`) are only online; the dev/build output carries the error's fix options. Exact exports are also in `node_modules/next/{server,navigation,headers,cache}.d.ts`. ## Next.js 16 changes older examples miss - Sync request access is removed: `cookies()`, `headers()`, `draftMode()`, `params` (including image-metadata routes), `searchParams` and sitemap `id` are promises. `next typegen` generates global `PageProps<'/route'>`, `LayoutProps` and `RouteContext` types. - `middleware.ts` is deprecated: `proxy.ts` exporting `proxy` (or default) runs on Node.js only and rejects a `runtime` option; code that needs Edge stays in `middleware.ts`. Codemod: `npx @next/codemod@latest middleware-to-proxy .`. - Turbopack is the default for `dev` and `build`; a custom `webpack` config fails the build unless `--webpack` keeps it or explicit `--turbopack` ignores it. `next lint` is removed and `next build` no longer lints. `serverRuntimeConfig`/`publicRuntimeConfig` are removed. - Every parallel-route slot needs `default.tsx`, or the build fails. - `next/image`: `priority` is deprecated for `preload`; `qualities` defaults to `[75]` (other `quality` values are coerced); local `src` with a query string needs `images.localPatterns`; `images.domains` is deprecated for `remotePatterns`. - `revalidateTag(tag)` is deprecated; pass a profile such as `'max'` or `{ expire: 0 }` for immediate expiry. `updateTag` and `refresh` are Server Action-only. Caching details: `cache-components`. The params and proxy shapes, checked against next 16.3.8 (`next typegen`, `tsc --noEmit`, `next build`): ```tsx // app/blog/[slug]/page.tsx; PageProps is global after `next typegen` (or dev/build) export async function generateStaticParams() { return [{ slug: 'hello' }] // cacheComponents: needed for this top-level await; never [] } export default async function Page({ params }: PageProps<'/blog/[slug]'>) { const { slug } = await params // a Promise; sync access was removed in 16 return