Configs2026年3月29日·1 分钟阅读

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
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

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

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

介绍

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

🙏

来源与感谢

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

相关资产