nextjs-15

A set of coding rules for Next.js 15, a framework for building web applications with React. It covers the App Router, server-side components, data loading, forms, and styling.

In plain words
What is it for?
Use it when building or reviewing Next.js 15 applications, especially pages, data fetching, forms, and interactive components.
Why use it?
It gives developers consistent guidance for choosing where code runs and how common Next.js tasks should be organized.

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/renvia-code/best-cursor-rules/nextjs-15
Clone the repo
git clone --depth 1 https://github.com/Renvia-code/best-cursor-rules
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,624 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.01624
Opus 5 $0.00000 $0.00812
Sonnet 5 $0.00000 $0.00325
Haiku 4.5 $0.00000 $0.00162

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

Security

Grade A, and why

nextjs-15 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.

rules/frameworks/nextjs-15.mdc · 334 lines

How it starts

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

Next.js 15 Best Practices

Overview

Aspect Recommendation
Router App Router (default)
Components Server Components by default
Data Fetching async/await in Server Components
Forms Server Actions + useActionState
Styling Tailwind CSS or CSS Modules

Server Components (Default)

Server Components are the default in App Router. Only use 'use client' when needed.

When to use Client Components

'use client'  // Add ONLY when you need:

// ✅ Browser APIs (window, localStorage)
// ✅ Event handlers (onClick, onChange)
// ✅ Hooks (useState, useEffect, useContext)
// ✅ Third-party client libraries

✅ DO: Keep components server-side by default

// app/users/page.tsx - Server Component (no directive needed)
export default async function UsersPage() {
  const users = await getUsers()  // Direct database/API call
  return <UserList users={users} />
}

❌ DON'T: Add 'use client' unnecessarily

// Bad - this doesn't need to be a client component
'use client'
export default function About() {
  return <div>About us</div>  // No interactivity needed
}

Data Fetching

Fetch in Server Components

// app/products/page.tsx
async function getProducts() {
  const res = await fetch('https://api.example.com/products', {
    next: { revalidate: 3600 }  // Cache for 1 hour
  })
  return res.json()
}

export default async function ProductsPage() {
  const products = await getProducts()
  return <ProductGrid products={products} />
}

Cache Options

Option Use Case
{ cache: 'force-cache' } Static data (default)
{ cache: 'no-store' } Dynamic data (every request)
{ next: { revalidate: 60 } } ISR - revalidate every 60s

Server Actions

Form with Server Action

// app/actions.ts
'use server'

export async function createUser(formData: FormData) {
  const name = formData.get('name')
  await db.user.create({ data: { name } })
  revalidatePath('/users')
}

Read the full file on GitHub · 334 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 · 334 lines · 0 tokens per session scan A 371d0cf8ab3c

Subscribe to this mod's changes

nextjs-15 is a cursor rule published in the GitHub repository Renvia-code/best-cursor-rules (12 stars, last pushed 9mo ago), licensed CC0-1.0. It costs nothing until one of its globs matches a file; then it loads 1,624 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.