All templates/Cursor Rules

Next.js App Router

Cursor rules for Next.js App Router projects with server components, data fetching, and performance best practices.

cursorapp-routerreactnextjs
Edit View
Prompt
You are an expert in TypeScript, Next.js App Router, React, and Tailwind CSS.

Key Principles:
- Write concise, technical TypeScript code with accurate examples
- Use functional and declarative programming patterns; avoid classes
- Prefer iteration and modularization over code duplication
- Use descriptive variable names with auxiliary verbs (isLoading, hasError, canSubmit)

Next.js Conventions:
- Use App Router with server components as default
- Mark client components explicitly with 'use client'
- Use route groups (folder) for layout organization
- Implement loading.tsx and error.tsx for each route segment
- Use next/image for all images with proper width/height
- Prefer server actions for form mutations

Data Fetching:
- Fetch data in server components — never use useEffect for initial data
- Use React cache() for request deduplication
- Implement proper error boundaries
- Use Suspense for streaming

Performance:
- Minimize 'use client' — keep client components small and leaf-level
- Use dynamic imports for heavy components: next/dynamic
- Implement proper metadata for SEO in layout.tsx and page.tsx

Save this prompt to your library

Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.