Skip to main content
rule

typescript-nodejs-nextjs-react-ui-css-cursorrules- — rule for Cursor

A Cursor rule that pins down how the agent writes TypeScript, Next.js App Router, React and Tailwind code. Useful when generated components drift from your conventions.

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

What typescript-nodejs-nextjs-react-ui-css-cursorrules- does

The file lives at .cursor/rules/typescript-nodejs-nextjs-react-ui-css-cursorrules-.mdc and targets files matching **/*. Inside is a set of conventions: functional and declarative patterns instead of classes, interfaces over types, the function keyword for pure functions, named exports for components. Directories use lowercase with dashes, like components/auth-wizard.

For UI the rule leans on Shadcn UI, Radix UI and Tailwind, with a mobile-first approach to layout. A performance section asks for fewer use client, useEffect and setState calls, React Server Components as the default, client components wrapped in Suspense with a fallback, dynamic loading for non-critical parts, and WebP images with size data and lazy loading. URL search parameter state goes through nuqs.

Auto-apply is off: alwaysApply: false. The rule will not attach itself to your requests, so you have to reference it manually — otherwise the agent never sees it. Worth knowing before you expect the style to change right after dropping the file in.

What it helps with

  • set one TypeScript code style for the agent across a project
  • steer component generation away from classes toward functional patterns
  • cut down on client components in favour of React Server Components
  • settle directory naming and component export conventions
  • standardise on Tailwind and Shadcn UI for styling

Example prompts for the agent

  • Rewrite this component following the project rules: functional style, named export, interface instead of type
  • Find where we can drop use client and let the server render this
  • Build the form with Shadcn UI and Tailwind, mobile-first, keep filter state in the URL via nuqs

How to install typescript-nodejs-nextjs-react-ui-css-cursorrules-

Manually: put the files in place

.cursor/rules/typescript-nodejs-nextjs-react-ui-css-cursorrules-.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 typescript-nodejs-nextjs-react-ui-css-cursorrules-

How do I install typescript-nodejs-nextjs-react-ui-css-cursorrules- in Cursor?

Copy the file into your project at .cursor/rules/typescript-nodejs-nextjs-react-ui-css-cursorrules-.mdc. There is no install command — the rule works from that folder.

What does this rule do?

It describes how to write TypeScript, Node.js, Next.js App Router, React, Shadcn UI, Radix UI and Tailwind code: file structure, naming, exports, and how to handle client components and images.

Why doesn't the rule apply on its own?

It sets alwaysApply: false, so Cursor does not pick it up automatically. Attach the file to a request when you want these conventions in play.

Source text

typescript-nodejs-nextjs-react-ui-css-cursorrules-.mdc · CC0-1.0
---
description: "Cursor rules for TypeScript development with Node.js, Next.js, React, UI, and CSS integration."
globs: **/*
alwaysApply: false
---
You are an expert in TypeScript, Node.js, Next.js App Router, React, Shadcn UI, Radix UI and Tailwind.

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

- 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, Radix, 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.

© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set68

vitest-unit-testing-cursorrules-prompt-file A Cursor rule that turns the agent into a Vitest and TypeScript test writer: it targets business logic and utilities, mocking dependencies with vi.mock. ★ 41,011repo stars unity-cursor-ai-c-cursorrules-prompt-file A Cursor rule that briefs the assistant on a Unity game project in C#: modular code, responsive mechanics, real-time performance. ★ 41,011repo stars typescript A Cursor rule that pins down how the agent writes TypeScript: types, naming, error handling. Useful when several people touch the same codebase. ★ 41,011repo stars typescript-vite-tailwind-cursorrules-prompt-file A Cursor rule that pins down TypeScript code style for Vue projects built with Vite and styled with Tailwind. Useful when you want the agent's output to stay predictable. ★ 41,011repo stars typescript-nextjs-supabase-cursorrules-prompt-file A Cursor rule that keeps TypeScript work on Next.js App Router and Supabase consistent: server components first, Shadcn UI, Tailwind. ★ 41,011repo stars typescript-code-convention-cursorrules-prompt-file A Cursor rule that pins down TypeScript code style for Next.js App Router, React, Expo, tRPC and Tailwind projects. Useful when the agent writes code inconsistently. ★ 41,011repo stars tauri-svelte-typescript-guide-cursorrules-prompt-f A Cursor rule that sets how the agent writes desktop apps with Tauri: Svelte on the frontend, TypeScript for types. ★ 41,011repo stars tanstack-router A Cursor rule that sets agent conventions for TanStack Router v1: file-based routes, typed params and loader-based data fetching. ★ 41,011repo 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