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.

More: all Next.js rules · all Cursor rules

Related rules

Next.js AGENTS.md

AGENTS.md for Next.js 16 App Router projects: commands, folder layout, data access, auth, and done criteria.

AGENTS.mdNext.js

Next.js App Router (TypeScript) rules

Cursor project rules for Next.js 15 App Router apps with TypeScript, Server Components, and Tailwind.

CursorNext.js

Next.js CLAUDE.md

A CLAUDE.md for Claude Code working in a Next.js + Prisma + Tailwind codebase.

Claude Code (CLAUDE.md)Next.js

Next.js Server Actions Copilot path instructions

Path-specific Copilot instructions for Next.js Server Actions and route handlers: validation, auth, and revalidation.

GitHub CopilotNext.js

Next.js Windsurf rules

Windsurf (Cascade) workspace rules for Next.js + shadcn/ui projects.

WindsurfNext.js

Astro content site rules

Cursor rules for Astro 5 sites with content collections, islands, and zero-JS-by-default pages.

CursorAstro

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.