Home › Next.js › Next.js 16 rules (Cache Components, proxy.ts)
Next.js 16 rules (Cache Components, proxy.ts)
Cursor rules for Next.js 16 App Router: Cache Components with "use cache", proxy.ts, async request APIs, Turbopack.
CursorNext.js
How to use
Save this as .cursor/rules/nextjs-16.mdc in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.
Note: Review and test before use. Provided as is, without warranty. See Terms.
.cursor/rules/nextjs-16.mdcDownload ---
description: Next.js 16 (Cache Components, proxy.ts) conventions
globs: ["app/**/*.{ts,tsx}","proxy.ts","next.config.ts"]
alwaysApply: false
---
# Next.js 16
- Server Components by default. Add `"use client"` only to the leaf that needs state, effects, or browser APIs.
- Request APIs are async: `const { slug } = await params`, `await searchParams`, `await cookies()`, `await headers()`. Type pages with `PageProps<'/blog/[slug]'>` if the project uses typed routes.
- Caching is opt-in with Cache Components (`cacheComponents: true`): mark cached functions/components with `"use cache"`, set lifetimes with `cacheLife('hours')`, tag with `cacheTag('posts')`. Everything else is dynamic per request.
- Wrap dynamic parts in `<Suspense>` with a real fallback so the static shell streams first.
- After mutations in Server Actions, call `updateTag('posts')` (read-your-writes) or `revalidateTag('posts', 'max')`; use `revalidatePath` only when tags don't fit.
- Request interception lives in `proxy.ts` (export `proxy`), which replaced `middleware.ts`. Keep it light: redirects, rewrites, auth gate. Real authorization happens again in the data layer.
- Server Actions validate input (zod), check the session, and return typed results; never trust form fields for ids you didn't authorize.
- Turbopack is the default bundler for `next dev` and `next build`; don't add webpack-only config without checking.
- Lint with ESLint directly (`eslint .`); `next lint` was removed.
- Images via `next/image`, fonts via `next/font`, metadata via `generateMetadata`.
## Done when
`npx tsc --noEmit`, `npx eslint .`, and `npm run build` pass.