nextjs

A set of coding rules for building Next.js applications with the App Router, which uses the app/ folder to define pages and routes. It covers server-rendered components, data loading, and server-side actions.

In plain words
What is it for?
Use it when creating or changing Next.js pages, route components, data fetching, loading and error states, or server actions.
Why use it?
It gives the coding agent consistent guidance about where code belongs and how Next.js features should be used. This reduces misplaced logic, unnecessary browser code, and inconsistent data handling.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/nedcodes-ok/cursor-doctor/nextjs
Clone the repo
git clone --depth 1 https://github.com/nedcodes-ok/cursor-doctor
Per session 842 This file is loaded in full into every session.
When invoked 842 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00842 $0.00842
Opus 5 $0.00421 $0.00421
Sonnet 5 $0.00168 $0.00168
Haiku 4.5 $0.00084 $0.00084

Measured 2d ago against content hash 4f3cdbb53d04, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

nextjs scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

100% identical to nextjs — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

pro-kit/templates/frameworks/nextjs.mdc · 54 lines

How it starts

The opening of the file, as written. The whole thing — 54 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Next.js Cursor Rules

You are an expert Next.js developer using App Router (v14+). Follow these rules:

Architecture

  • Use App Router (app/ directory) for all new code
  • Default to Server Components. "use client" only for interactivity/hooks/browser APIs
  • "use client" marks the boundary — everything imported into a client component becomes client too, even if not marked. Keep client boundaries as low in the tree as possible
  • Use route groups (parentheses folders) for organization without URL impact
  • Keep page.tsx thin — compose from smaller components, page only wires them together
  • Colocate components with their route: app/dashboard/_components/ not a global components/ folder

Data Fetching

  • Fetch in Server Components with async/await — no useEffect for server data
  • fetch() requests with the same URL and options are automatically deduped within a render pass — don't cache manually
  • Use next: { revalidate: seconds } for time-based ISR, next: { tags: [...] } for on-demand with revalidateTag()
  • Server Actions for mutations — they run server-side even when called from client components
  • loading.tsx for Suspense boundaries per route segment, error.tsx for error boundaries
  • Do not fetch in layouts if child routes need different data — layouts don't re-render on navigation

Rendering Gotchas

  • Static rendering is default. Using cookies(), headers(), or searchParams opts the entire route into dynamic rendering — isolate dynamic parts with Suspense
  • generateStaticParams for dynamic route pre-rendering at build time — without it, dynamic segments are rendered on-demand
  • for all images (handles lazy loading, srcset, WebP). Set explicit width/height or use fill with a sized parent — unsized images cause layout shift
  • Do not import server-only code in client components — use the server-only package to get a build-time error instead of a runtime leak

Read the full file on GitHub · 54 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 54 lines · 842 tokens per session scan A 4f3cdbb53d04

Subscribe to this mod's changes

nextjs is a cursor rule published in the GitHub repository nedcodes-ok/cursor-doctor (9 stars, last pushed 5mo ago), licensed MIT. It adds 842 tokens to every session, about $0.0042 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to nextjs, differing in 0 lines, and is treated as a copy.