Skip to main content
rule

typescript-shadcn-ui-nextjs-cursorrules-prompt-fil — Cursor rule

Sets TypeScript, React Server Component, and shadcn/ui coding standards for Next.js in Cursor. Helpful when building mobile-first interfaces with Tailwind CSS and Radix.

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

What typescript-shadcn-ui-nextjs-cursorrules-prompt-fil does

The rule configures code generation for Next.js projects with React Server Components. It restricts 'use client' strictly to small components requiring browser Web APIs, keeping data fetching on the server. Expected Server Action errors must be modeled as return values, while form inputs rely on Zod schemas.

Styling follows a mobile-first layout using Tailwind CSS, Radix, and shadcn/ui. URL search parameters are handled through the nuqs library. The rule enforces pure functions with the function keyword and object maps instead of TypeScript enums. Interfaces are strictly preferred over type aliases.

The stack is strictly pinned. Without Next.js, Zod, and Tailwind CSS in your project, the assistant will generate conflicting code patterns.

What it helps with

  • restrict unjustified 'use client' usage in Next.js
  • validate form inputs with Zod in Server Actions
  • structure shadcn/ui and Radix components with mobile-first Tailwind CSS
  • manage URL search parameter state using nuqs

Example prompts for the agent

  • Build a login form component using shadcn/ui, Zod validation, and a Server Action
  • Move catalog filters into a client component that syncs search state with nuqs
  • Refactor this card component into a React Server Component with WebP image loading

How to install typescript-shadcn-ui-nextjs-cursorrules-prompt-fil

Manually: put the files in place

.cursor/rules/typescript-shadcn-ui-nextjs-cursorrules-prompt-fil.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-shadcn-ui-nextjs-cursorrules-prompt-fil

How to install typescript-shadcn-ui-nextjs-cursorrules-prompt-fil in Cursor?

Save the rule file to .cursor/rules/typescript-shadcn-ui-nextjs-cursorrules-prompt-fil.mdc in your project root.

What does typescript-shadcn-ui-nextjs-cursorrules-prompt-fil do?

It guides Cursor to favor React Server Components, prioritize interfaces over types, avoid enums, and construct interfaces using shadcn/ui with Tailwind CSS.

Which libraries are required for this rule?

The rule assumes your repository includes Next.js, Zod for validation, nuqs for URL query state, alongside Radix UI and Tailwind CSS.

Source text

typescript-shadcn-ui-nextjs-cursorrules-prompt-fil.mdc · CC0-1.0
---
description: "Cursor rules for TypeScript development with shadcn/ui and Next.js integration."
globs: **/*
alwaysApply: false
---
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

Error Handling and Validation:

- Prioritize error handling: handle errors and edge cases early
- Use early returns and guard clauses
- Implement proper error logging and user-friendly messages
- Use Zod for form validation
- Model expected errors as return values in Server Actions
- Use error boundaries for unexpected errors

UI and Styling:

- Use Shadcn UI, Radix, and Tailwind Aria 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 set234

The whole set →
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,024repo stars typescript-zod-tailwind-nextjs-cursorrules-prompt- Cursor coding standard for Next.js and TypeScript: enforces functional patterns, Zod validation, Shadcn UI, and desktop-first Tailwind CSS. ★ 41,024repo stars typescript-vuejs-cursorrules-prompt-file A Cursor rule that tells the agent how to write TypeScript inside Vue.js projects. Useful when you want edits across components to follow the same conventions. ★ 41,024repo 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,024repo stars typescript-react-nextui-supabase-cursorrules-promp This rule gives an agent context for a TypeScript app built with React, NextUI, and Supabase. Use it when working on the UI, user dashboard, or authentication flows. ★ 41,024repo stars typescript-react-nextjs-cloudflare-cursorrules-pro A Cursor rule that points the agent at TypeScript, Next.js App Router, React and Cloudflare tooling. Useful when your project already runs on that stack. ★ 41,024repo stars typescript-react-cursorrules-prompt-file Cursor rule establishing standards for TypeScript and React codebases. It enforces functional components, strict typing, and a standard folder layout. ★ 41,024repo stars typescript-nodejs-react-vite-cursorrules-prompt-fi This rule sets TypeScript conventions for Node.js, React, and Vite projects, with guidance for TanStack Query, TanStack Router, and Tailwind. Use it to keep agent edits aligned with your codebase’s existing style. ★ 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