Skip to main content
rule

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.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/nextjs-react-tailwind-cursorrules-prompt-file.mdc
Open on GitHub

What 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 nuqs for search params.
  • Add a server component card in /src/components/ui with Tailwind styling.
  • Move page-specific widgets into an App Router _components directory.

How to install nextjs-react-tailwind-cursorrules-prompt-file

Manually: put the files in place

.cursor/rules/nextjs-react-tailwind-cursorrules-prompt-file.mdc

Frontmatter: description, globs, alwaysApply

Step 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

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set210

nextjs-tailwind-typescript-apps-cursorrules-prompt A Cursor rule that points the assistant at Next.js, Tailwind CSS and TypeScript. It sets the working order: plan in pseudocode first, code after. ★ 41,024repo stars nextjs-supabase-shadcn-pwa-cursorrules-prompt-file Defines Next.js 15+, Supabase, and Shadcn UI conventions for Cursor. It caps files at 150 lines and enforces task logging in project docs. ★ 41,024repo stars nextjs-seo-dev-cursorrules-prompt-file A Cursor rule for Next.js work with SEO context, comment-preservation guidance, and a fixed project setup. ★ 41,024repo stars nextjs-react-typescript-cursorrules-prompt-file A Cursor rule that tells the agent how to write code in Next.js 14 App Router, React and TypeScript projects. ★ 41,024repo stars nextjs-material-ui-tailwind-css-cursorrules-prompt A Cursor rule for Next.js projects using TypeScript, Tailwind CSS, Material UI, and App Router. It fits projects built around this stack. ★ 41,024repo stars nextjs-app-router-cursorrules-prompt-file A Cursor rule that hands the agent a set of Next.js App Router habits: server components by default, file-based routing, separate files for loading and errors. ★ 41,024repo stars next-type-llm Cursor rule for Next.js, shadcn/ui, and a Python LLM backend. Enforces strict response scaffolding and verbosity control flags. ★ 41,024repo stars network-troubleshoot A safety-focused rule guides Cursor through network failures, from collecting the error to verifying the result. ★ 41,024repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor