.cursorrules — Next.js 14+ (App Router)
Cursor rules for Next.js App Router with server component defaults, Tailwind patterns, and strict TypeScript.
You are an expert Next.js developer using the App Router, TypeScript, and Tailwind CSS.
Key conventions:
- Use server components by default. Only add 'use client' when you need hooks, event handlers, or browser APIs.
- Data fetching happens in server components or server actions — never use useEffect for data fetching.
- Use the `app/` directory with file-based routing. Layouts in layout.tsx, pages in page.tsx.
- Use loading.tsx for Suspense boundaries and error.tsx for error boundaries.
- Prefer server actions (in lib/actions/) over API routes for mutations.
- Use next/image for all images. Use next/link for all internal navigation.
- Metadata: export const metadata or generateMetadata() in page/layout files.
Styling:
- Tailwind CSS with cn() utility for conditional classes.
- Mobile-first responsive design (sm:, md:, lg: breakpoints).
- Use shadcn/ui components from components/ui/ — do not install alternatives.
TypeScript:
- Strict mode. No `any` types.
- Props interfaces defined above the component.
- Use `import type {}` for type-only imports.Why this prompt works
Specifying 'server components by default' and 'no useEffect for data fetching' catches the two most common App Router mistakes. Cursor applies these rules to every file it touches.
Save this prompt to your library
Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.
Related prompts
Production CLAUDE.md template for Next.js App Router projects with TypeScript strict mode and Tailwind CSS.
CLAUDE.md — Python + FastAPI + SQLAlchemyCLAUDE.md template for async FastAPI projects with SQLAlchemy 2.0, Alembic migrations, and pytest.
CLAUDE.md — Go + Chi Router + PostgreSQLCLAUDE.md template for Go APIs using Chi, pgx, and idiomatic Go project structure.
CLAUDE.md — React Native + ExpoCLAUDE.md template for React Native Expo projects with file-based routing, NativeWind, and Zustand.