ConfigsMar 29, 2026·1 min read

Cursor Rules: Next.js — Best Practices for AI Coding

Cursor rules file for Next.js projects. Configures AI to follow App Router patterns, server components, TypeScript conventions, and Tailwind CSS best practices.

TO
TokRepo精选 · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

Create .cursor/rules/nextjs.mdc in your project root:

---
description: Next.js App Router best practices
globs: ["**/*.tsx", "**/*.ts", "app/**/*"]
---

Intro

A comprehensive Cursor rules file that teaches the AI assistant Next.js 14+ best practices. Covers App Router patterns, Server vs Client Components, data fetching, TypeScript conventions, and Tailwind CSS integration.

Best for: Next.js developers using Cursor IDE Works with: Cursor


What It Covers

Architecture

  • App Router directory structure (app/, components/, lib/)
  • Server Components by default, Client Components only when needed
  • Route groups, layouts, loading/error boundaries

Code Patterns

  • use server and use client directives
  • Server Actions for mutations
  • generateMetadata for SEO
  • ISR and dynamic rendering strategies

Conventions

  • TypeScript strict mode
  • Tailwind CSS for styling (no CSS modules)
  • cn() utility for conditional classes
  • Named exports for components

Example Rule

You are an expert Next.js developer.

Key principles:
- Use Server Components by default
- Only add "use client" when you need interactivity
- Use Server Actions for form mutations
- Prefer fetch() with Next.js caching over client-side data fetching
- Use TypeScript strict mode
- Style with Tailwind CSS utility classes

🙏

Source & Thanks

Curated from the cursor.directory community. Based on Next.js documentation best practices.

Related Assets