Home › All rules › Community › Next.js Cursor Rules

Next.js Cursor Rules

Next.js with TypeScript and Tailwind UI best practices

CursorNext.jsCommunity (CC0)

How to use

Save this as .cursor/rules/nextjs.mdc in your project, commit it, and Cursor will load it. Review it first: community files can be opinionated or out of date.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.cursor/rules/nextjs.mdcDownload  
---
description: "Next.js with TypeScript and Tailwind UI best practices"
globs: **/*.tsx, **/*.ts, src/**/*.ts, src/**/*.tsx
alwaysApply: false
---
# Next.js Best Practices

## Project Structure
- Use the App Router directory structure
- Place components in `app` directory for route-specific components
- Place shared components in `components` directory
- Place utilities and helpers in `lib` directory
- Use lowercase with dashes for directories (e.g., `components/auth-wizard`)

## Components
- Use Server Components by default
- Mark client components explicitly with 'use client'
- Wrap client components in Suspense with fallback
- Use dynamic loading for non-critical components
- Implement proper error boundaries
- Place static content and interfaces at file end

## Performance
- Optimize images: Use WebP format, size data, lazy loading
- Minimize use of 'useEffect' and 'setState'
- Favor Server Components (RSC) where possible
- Use dynamic loading for non-critical components
- Implement proper caching strategies

## Data Fetching
- Use Server Components for data fetching when possible
- Implement proper error handling for data fetching
- Use appropriate caching strategies
- Handle loading and error states appropriately

## Routing
- Use the App Router conventions
- Implement proper loading and error states for routes
- Use dynamic routes appropriately
- Handle parallel routes when needed

## Forms and Validation
- Use Zod for form validation
- Implement proper server-side validation
- Handle form errors appropriately
- Show loading states during form submission

## State Management
- Minimize client-side state
- Use React Context sparingly
- Prefer server state when possible
- Implement proper loading states

More: Next.js rules · all community rules

Related rules

Next.js 16 rules (Cache Components, proxy.ts)

Cursor rules for Next.js 16 App Router: Cache Components with "use cache", proxy.ts, async request APIs, Turbopack.

CursorNext.js

Next.js AGENTS.md

AGENTS.md for Next.js 16 App Router projects: commands, folder layout, data access, auth, and done criteria.

AGENTS.mdNext.js

Next.js App Router (TypeScript) rules

Cursor project rules for Next.js 15 App Router apps with TypeScript, Server Components, and Tailwind.

CursorNext.js

Cursor AI Next.js 14 Tailwind Seo Setup Cursor Rules

Cursor rules for Next.js development with Tailwind CSS and SEO optimization.

CursorNext.jsCommunity (CC0)

Next.js App Router Cursor Rules

Cursor rules for Next.js development with App Router integration.

CursorNext.jsCommunity (CC0)

Next.js Material Ui Tailwind Css Cursor Rules

Cursor rules for Next.js development with Material UI and Tailwind CSS integration.

CursorNext.jsCommunity (CC0)

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.