app-router

app-router is a cursor rule for Cursor from bernierllc/agents-environment-config. It costs 0 tokens per session (1,492 once invoked), scanned A, original, MIT.

Rules for building Next.js applications with the App Router, a system for organising pages and navigation, along with React component and project-structure guidance.

In plain words
What is it for?
It helps structure pages, organise files, and create React components in Next.js applications.
Why use it?
It helps keep Next.js projects organised and applies consistent patterns when building their user interfaces.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit It helps structure pages, organise files, and create React components in Next.js applications.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/bernierllc/agents-environment-config/app-router
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.

Clone the repo
git clone --depth 1 https://github.com/bernierllc/agents-environment-config

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for app-router

README.md
[![agentmods](https://agentmods.dev/badge/rules/bernierllc/agents-environment-config/app-router/github.svg)](https://agentmods.dev/rules/bernierllc/agents-environment-config/app-router)
Your own site
<a href="https://agentmods.dev/rules/bernierllc/agents-environment-config/app-router"><img src="https://agentmods.dev/badge/rules/bernierllc/agents-environment-config/app-router/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for app-router

Your own site · 80×15
<a href="https://agentmods.dev/rules/bernierllc/agents-environment-config/app-router"><img src="https://agentmods.dev/badge/rules/bernierllc/agents-environment-config/app-router.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,492 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00000 $0.01492
Opus 5.5 $0.00000 $0.00597
Sonnet 5.5 $0.00000 $0.00298
Haiku 4.5 $0.00000 $0.00149

Measured 1mo ago against content hash b93ddffb2b44, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

app-router 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 1mo 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/stacks/nextjs/app-router.mdc · 225 lines

How it starts

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

Next.js App Router & React Standards

Next.js App Router Patterns

Server Components (Default)

Server components are the default in Next.js App Router. Only use client components when interactivity is needed.

// ✅ DEFAULT: Server Component (no 'use client')
export default function Page() {
  // Server-side rendering by default
  return <div>Server Component</div>;
}

Client Components (Explicit)

Only mark components as client components when they need interactivity.

// ✅ EXPLICIT: Only when needed
'use client';

import { useState } from 'react';

export function InteractiveButton() {
  const [count, setCount] = useState(0);
  return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
}

File Structure (App Router)

src/app/
├── layout.tsx           # Root layout
├── page.tsx            # Home page
├── loading.tsx         # Loading UI
├── error.tsx           # Error boundary
├── not-found.tsx       # 404 page
├── dashboard/
│   ├── layout.tsx      # Nested layout
│   ├── page.tsx        # Dashboard page
│   └── users/
│       └── page.tsx    # Users page
└── api/
    └── users/
        └── route.ts    # API endpoint

Component Standards

Functional Components with TypeScript

All React components must have proper TypeScript interfaces and explicit return types.

// ✅ REQUIRED: Props interface + explicit return type
interface UserCardProps {
  user: User;
  onSelect?: (user: User) => void;
  className?: string;
}

export function UserCard({ 
  user, 
  onSelect, 
  className 
}: UserCardProps): JSX.Element {
  return (
    <div 
      className={`border-gray-200 shadow-sm ${className}`}
      onClick={() => onSelect?.(user)}
    >
      <h3 className="text-gray-900">{user.name}</h3>
      <p className="text-gray-700">{user.email}</p>
    </div>
  );
}

Data Testid Requirements (MANDATORY)

Add data-testid to all interactive elements, dynamic state containers, and structural landmarks when building components. This is a build-time requirement, not a testing afterthought.

Read the full file on GitHub · 225 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. 1mo ago First seen · 225 lines · 0 tokens per session scan A b93ddffb2b44

Subscribe to this mod's changes

app-router is a cursor rule published in the GitHub repository bernierllc/agents-environment-config (11 stars, last pushed yesterday), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,492 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-31.