NextJS15

Rules for building Next.js 15 applications with TypeScript and Tailwind, covering project structure, components, rendering, loading, and errors. Next.js is a framework for building web applications.

In plain words
What is it for?
Structuring App Router projects, placing shared code, deciding between server and browser components, loading content dynamically, and handling errors.
Why use it?
It provides consistent conventions for organising the code and choosing how pages and components should run.

Cursor rule for Cursor

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/thesethrose/devrules/nextjs15
Clone the repo
git clone --depth 1 https://github.com/TheSethRose/DevRules

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,428 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found 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.00000 $0.01428
Opus 5 $0.00000 $0.00714
Sonnet 5 $0.00000 $0.00286
Haiku 4.5 $0.00000 $0.00143

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

Security

Grade A, and why

NextJS15 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.

.cursor/rules/technologies/NextJS15.mdc · 95 lines

How it starts

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

Next.js Best Practices

Project Structure

  • Use the App Router directory structure (app/, components/, lib/ are common top-level folders).
  • Place route-specific components, layouts, pages, loading/error UIs within the app directory following App Router conventions.
  • Place shared, reusable components outside the app directory (e.g., in components/).
  • Place utilities, helpers, constants, and types in lib/ or utils/.
  • Use lowercase kebab-case for directory and file names (e.g., components/auth-wizard, app/user-profile/page.tsx).

Components & Rendering

  • Use Server Components by default for better performance and data fetching.
  • Mark components requiring interactivity, browser APIs, or state/lifecycle hooks explicitly with 'use client' at the top.
  • Prefer passing Server Components as props (children) to Client Components where possible to minimize Client bundle size.
  • Wrap Client Components that suspend (e.g., data fetching with hooks) in <Suspense> with an appropriate fallback UI.
  • Use next/dynamic for dynamic loading of components that are not critical for the initial page load.
  • Implement proper error boundaries (error.tsx files in the App Router) to handle runtime errors gracefully.
  • Place static content, constants, and type/interface definitions towards the end of the file for readability.

Performance

  • Optimize images using next/image: Ensure proper width, height, priority props, consider fill prop, and use modern formats like WebP if applicable.
  • Minimize unnecessary use of useEffect and client-side state (useState) in Client Components. Fetch data on the server where possible.
  • Favor Server Components (RSC) for data fetching and rendering static content.
  • Implement caching strategies effectively: Utilize Next.js fetch caching, Route Segment caching, and consider revalidate options. Understand the difference between static and dynamic rendering.

Data Fetching

  • Primarily use Server Components for data fetching (async/await directly in components).
  • Use Route Handlers (route.ts) for API endpoints.
  • Implement proper error handling (e.g., try/catch) for data fetching operations.
  • Utilize Next.js extended fetch API options for caching and revalidation (cache, next.revalidate).
  • Handle loading states using loading.tsx files or <Suspense> boundaries.
  • Handle error states using error.tsx files.

Read the full file on GitHub · 95 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 · 95 lines · 1,428 tokens per session scan A 16c8b4df6ae5

Subscribe to this mod's changes

NextJS15 is a cursor rule published in the GitHub repository TheSethRose/DevRules (25 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,428 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.