Next.js React Tailwind .cursorrules prompt file
Author: Shreyas Prakash
What you can build
Component Library Generator: Create a tool that automates the generation of component libraries based on Shadcn UI, Tailwind, and TypeScript. It would allow developers to input component specifications and receive organized, stylized, and ready-to-use code.Responsive UI Design Tool: Develop a web application that allows users to design and visualize responsive interfaces using Tailwind and Shadcn UI. Users can see real-time previews of their designs across various device sizes and export the code in TypeScript.Code Quality Analyzer for Typescript Projects: Build an application that analyzes TypeScript codebases, ensuring adherence to best practices such as coding styles, naming conventions, and UI guidelines. It could also provide optimization suggestions for performance and web vitals.Node.js Server-Client Architecture Checker: An application that reviews Node.js projects to evaluate the distribution of server and client components, suggesting possible optimizations for performance and scalability within a Next.js environment.Lazy Loading and Image Optimization Service: A plugin or extension that automatically implements lazy loading and image optimization for web projects, ensuring use of lazy loading techniques for images and adopting WebP formats.Dynamic Import Scheduler: Create a scheduler tool for web apps that identifies non-critical components and suggests optimal points for dynamic imports, enhancing performance without affecting user experience.'Nuqs' State Management Integrator: Develop a library that seamlessly integrates 'nuqs' URL search parameter state management into Next.js applications, guiding developers on effective state management using best practices.Tailwind CSS Customization Platform: A platform that allows developers to create and customize Tailwind CSS themes with visualization tools, coding examples, and export options, tailored for use with TypeScript projects.Next.js Project Structuring Template: Offer a template or generator for creating new Next.js projects with the recommended /src/app and /src/components folder structure to ensure an organized and scalable architecture.FRAMER Motion Animation Library with React Hooks: Construct a library offering pre-designed Framer Motion animations encapsulated within React hooks to streamline the implementation of advanced animations in projects.
Benefits
Synopsis
Developers building scalable, organized Next.js projects with TypeScript, React, and Tailwind will benefit from this prompt's guidelines to maintain structure, performance, and readability.
Overview of .cursorrules prompt
The .cursorrules file outlines coding conventions and organizational best practices for a TypeScript project using Node.js, Next.js App Router, React, Shadcn UI, Tailwind, and Framer Motion. It emphasizes concise and technical coding styles, preferring functional and declarative programming patterns. The file suggests using descriptive naming conventions, TypeScript interfaces over types, and avoiding certain patterns like enums. It highlights the importance of file structuring, responsive UI design with Tailwind CSS, and performance optimization techniques such as limiting client-side interactions and employing server components. The organization of the components is suggested to be either by type or feature within a structured directory layout, enhancing modularity and scalability. The project structure under a /src directory is emphasized for clarity and adherence to industry standards.
.cursorrules Content
- 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 https://placekitten.com/ - 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 OrganizationWithin 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 domainsFor 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