nextjs-react-tailwind-cursorrules-prompt-file — Cursor rule
Sets coding instructions for Next.js App Router, React, Tailwind CSS, and Shadcn UI. Enforces React Server Components and a clean file layout in Cursor.
.cursor/rules/nextjs-react-tailwind-cursorrules-prompt-file.mdcWhat nextjs-react-tailwind-cursorrules-prompt-file does
This rule configures Cursor for projects built on Next.js App Router, TypeScript, and Tailwind CSS. It avoids classes. The model relies on interfaces rather than types.
The guidelines limit 'use client' strictly to small interactive widgets or Web API access. Data fetching stays in server components. For URL search parameter state, the rule requires nuqs, while non-critical UI elements must be dynamically imported or wrapped in Suspense.
Project structure requires both /app and /components under /src. Files use kebab-case names like new-component.tsx. Because the instructions assume Next.js App Router conventions, projects running on Pages Router will face conflicting outputs.
What it helps with
- enforce server components over client-side state
- standardize file naming and layout inside
/src/components - handle search parameters through
nuqs - ban TypeScript classes and enums in UI code
Example prompts for the agent
- Build a product filter component using
nuqsfor search params. - Add a server component card in
/src/components/uiwith Tailwind styling. - Move page-specific widgets into an App Router
_componentsdirectory.
How to install nextjs-react-tailwind-cursorrules-prompt-file
Manually: put the files in place
.cursor/rules/nextjs-react-tailwind-cursorrules-prompt-file.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/nextjs-react-tailwind-cursorrules-prompt-file.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/nextjs-react-tailwind-cursorrules-prompt-file.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/nextjs-react-tailwind-cursorrules-prompt-file.mdManually: put the files in place
.clinerules/nextjs-react-tailwind-cursorrules-prompt-file.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about nextjs-react-tailwind-cursorrules-prompt-file
How to install nextjs-react-tailwind-cursorrules-prompt-file in Cursor?
Add the rule contents to .cursor/rules/nextjs-react-tailwind-cursorrules-prompt-file.mdc in your workspace root.
What does nextjs-react-tailwind-cursorrules-prompt-file do?
It guides Cursor to generate Next.js App Router code using React Server Components, Tailwind CSS, and Shadcn UI. It also enforces TypeScript interfaces, named exports, and strict folder structures.
Which libraries does this rule expect in the project?
It targets setups with Next.js App Router, Tailwind CSS, Shadcn UI, Framer Motion, and nuqs for query string state.
Source text
nextjs-react-tailwind-cursorrules-prompt-file.mdc · CC0-1.0
---
description: "Cursor rules for Next.js development with React and Tailwind CSS integration."
globs: **/*
alwaysApply: false
---
- You are an expert in TypeScript, Node.js, Next.js App Router, React, Shadcn UI, and Tailwind and Framer Motion.
- Code Style and Structure
- 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 (e.g., isLoading, hasError).
- Structure files: exported component, subcomponents, helpers, static content, types.
- Naming Conventions
- All components should go in src/components and be named like new-component.tsx
- Use lowercase with dashes for directories (e.g., components/auth-wizard).
- Favor named exports for components.
- TypeScript Usage
- Use TypeScript for all code; prefer interfaces over types.
- Avoid enums; use maps instead.
- Use functional components with TypeScript interfaces.
- Syntax and Formatting
- Use the "function" keyword for pure functions.
- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.
- Use declarative JSX.
- UI and Styling
- Use Shadcn UI, and Tailwind for components and styling.
- Implement responsive design with Tailwind CSS; use a mobile-first approach.
- Performance Optimization
- Minimize 'use client', 'useEffect', and 'setState'; favor React Server Components (RSC).
- Wrap client components in Suspense with fallback.
- Use dynamic loading for non-critical components.
- Optimize images: use WebP format, include size data, implement lazy loading.
- Key Conventions
- Use 'nuqs' for URL search parameter state management.
- Optimize Web Vitals (LCP, CLS, FID).
- Limit 'use client':
- Favor server components and Next.js SSR.
- Use only for Web API access in small components.
- Avoid for data fetching or state management.
- Follow Next.js docs for Data Fetching, Rendering, and Routing.
- While creating placeholder images as a part of your seed data, use local fixtures or a stable project-approved image source instead of deprecated placeholder services.
- Place both the /app and /components folders under a /src directory. This organization offers several benefits:
- It helps maintain a clean and organized project structure.
- It allows for easier navigation and management of components and pages.
- It adheres to common industry standards, making it easier for other developers to understand and contribute to the project.
- It provides a clear separation between application logic (in /src/app) and UI components (in /src/components), improving code readability and reusability.
- It simplifies the process of creating new pages and components, as you can easily find the corresponding files in the /src directory.
- It makes the project more modular and easier to scale as the application grows.
- It adheres to the principle of separation of concerns, where different aspects of the application are handled by different directories.
## Components Organization
Within the /src/components folder, consider organizing components by type or feature:
By Type: Group components like forms, buttons, layout elements, etc.
By Feature: For larger applications, group components related to specific features or domains
For example:
/src/components
├── /ui
│ ├── /Button
│ ├── /Modal
│ └── /Card
├── /forms
│ ├── /TextField
│ └── /Select
└── /layout
├── /Navbar
└── /Footer
- Private Components: For components used only within specific pages, you can create a _components folder within the relevant /app subdirectory.
- Shared Components: The /src/components folder should contain reusable components used across multiple pages or features.
- Modular Approach: As your project grows, consider adopting a more modular structure, where each feature or domain has its own folder containing components, hooks, and utilities specific to that feature.
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules