Sign in
Explore
Prompts · RulesWeb & UIReviewed

nextjs

Next.js with TypeScript and Tailwind: project structure and best practices.

Kind
Rules
Works with
Cursor
Languages
TypeScript / JavaScript
Source
Awesome Cursor Rules @ b044f956f021
Path
rules/nextjs.mdc
License
CC0-1.0
Jobs
Implementation
InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
# 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
…