19 nextjs rules available
Cursor has the largest Next.js collection here (19 exact matches), from a full App Router guide to short notes on middleware, caching and edge runtime. Note: the highest-ranked rule is titled "Next.js 14 App Router", but the App Router was introduced in Next.js 13 (beta) and marked stable in 13.4. The file below states the current rules the collection disagrees on.
Cursor applies project rules stored as .mdc files in .cursor/rules. Each rule's frontmatter (description, globs, alwaysApply) decides whether it is always included, attached to matching files, chosen by the agent from its description, or only used when you @-mention it. Cursor also reads AGENTS.md in the project root and subdirectories for plain-Markdown instructions.
.cursor/rules/nextjs.mdcStarting point, not a tested configuration for your repository. Attached when files matching the globs are in context (alwaysApply: false with globs). Review the instructions, adapt the file paths and run your project's existing checks.
--- description: "Next.js development project conventions" globs: "app/**/*.ts,app/**/*.tsx,src/app/**/*.ts,src/app/**/*.tsx" alwaysApply: false --- # Next.js instructions for Cursor ## Focus for this project - Do not use getServerSideProps, getStaticProps or next/router in app/; use async Server Components, generateStaticParams and next/navigation. - Treat caching as explicit: state the fetch cache or revalidate option you chose for each new data request. - For mutations, use Server Actions or route handlers and revalidate the affected paths. ## Next.js conventions - Check package.json for the Next.js major version and whether the project uses app/ (App Router) or pages/ (Pages Router); follow the router that already exists instead of mixing them. - Files under app/ are Server Components by default. Add "use client" only at the smallest component that needs state, effects, event handlers or browser APIs. - From Next.js 15, params, cookies() and headers() are asynchronous, and so is searchParams in page files: await them in pages, layouts, route handlers and generateMetadata. - Put API endpoints in route.ts files that export named HTTP-method functions (GET, POST, ...), and validate request bodies before using them. ## Before you finish - Run the project's lint script and next build (type errors and invalid route exports fail the build) and report the actual output. If you cannot run them, say so and list the exact commands instead of saying they pass. - Summarize which of the rules above affected the change. - If another attached Cursor rule conflicts with this one, name both rules and follow the one with the narrower globs.
Create your own Cursor rules for Next.js and share with the community.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
Cursor's docs recommend keeping individual rules under 500 lines and splitting large rules into composable ones. Cursor's documentation states that it supports AGENTS.md in the project root and in subdirectories. Use AGENTS.md for plain-Markdown instructions you also want other tools to read, and .mdc rules when you need Cursor's scoping options (globs, description-based selection, always-apply).
Documentation checked 2026-11-05: Cursor docs: Rules
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
You use Cursor's agent on a Next.js 15 or 16 project and want it to stop generating synchronous params access and Pages Router APIs in app/.
Convert pages/products/[id].tsx (getServerSideProps) to the App Router.
app/products/[id]/page.tsx as an async Server Component awaiting params, the fetch moved into the component with an explicit cache choice, notFound() for missing products, generateMetadata, and lint/build output.
Content reviewed 2026-11-05. Confirm instruction activation in your installed client before relying on it.
Cursor rule for React Server Components in the Next.js App Router covering client boundaries, serializable props, async params, streaming and secure Server Actions.