Modern Web Development
Brandon Fernandez's comprehensive cursor rules for modern web development with TypeScript, Node.js, Next.js 14, React, Supabase, GraphQL, Tailwind CSS, Radix UI, and Shadcn UI.
Key Development Principles
Code Style and Architecture
- Write concise, technical responses with accurate TypeScript examples
- Employ functional, declarative programming while avoiding class-based approaches
- Prioritize iteration and modularization over code duplication
- Use descriptive variable names with auxiliary verbs (
isLoading, hasError)
- Implement the RORO pattern (Receive an Object, Return an Object)
JavaScript/TypeScript Standards
- Use
function keyword for pure functions
- Omit semicolons
- Leverage TypeScript exclusively, preferring interfaces over types
- Structure files as: exported component, subcomponents, helpers, static content, types
- Minimize unnecessary curly braces in conditionals
Error Handling
- Address errors and edge cases at function entry points
- Apply early returns for error conditions avoiding deep nesting
- Position the success path last for improved readability
- Use guard clauses for precondition validation
- Implement user-friendly error messaging
React and Next.js Guidelines
- Use functional components with TypeScript interfaces
- Write declarative JSX using
function declarations
- Style with Shadcn UI, Radix, and Tailwind CSS
- Implement mobile-first responsive design
- Minimize
use client, useEffect, and setState - favor React Server Components
- Employ Zod for form validation
- Wrap client components in Suspense with fallbacks
- Use dynamic loading for non-critical components
- Optimize images (WebP format, size data, lazy loading)
Data and State Management
- Leverage React Server Components for data fetching
- Implement the preload pattern to prevent waterfalls
- Use Supabase for real-time synchronization and state management
- Consider Vercel KV for chat history, rate limiting, and sessions
Supabase and GraphQL
- Use Supabase client for database interactions and subscriptions
- Implement Row Level Security (RLS) policies
- Leverage Supabase Auth, Storage, and Edge Functions
- Use Genql for type-safe GraphQL API interactions
- Optimize GraphQL queries to fetch only necessary data
Styling and Testing
Styling
- Apply Tailwind CSS utility-first approach
- Use Class Variance Authority (CVA) for component variants
Testing
- Implement unit tests for utilities and hooks
- Create integration tests for complex components
- Develop end-to-end tests for critical user flows
Accessibility and Documentation
Accessibility
- Ensure keyboard navigation throughout interfaces
- Implement proper ARIA labels and semantic roles
- Maintain WCAG-compliant color contrast ratios
Documentation
- Provide clear JSDoc comments for IDE intellisense
- Document Supabase schemas, RLS policies, and Edge Functions
1---2name: modern-web-development3description: Modern web development best practices for TypeScript, Next.js 14, React Server Components, Supabase, GraphQL, and Tailwind CSS.4metadata:5 maintainer: Mindrally6 source: https://skillmd.com/skills/mindrally/modern-web-development7 upstream: https://github.com/Mindrally/skills8---910# Modern Web Development1112Brandon Fernandez's comprehensive cursor rules for modern web development with TypeScript, Node.js, Next.js 14, React, Supabase, GraphQL, Tailwind CSS, Radix UI, and Shadcn UI.1314## Key Development Principles1516### Code Style and Architecture1718- Write concise, technical responses with accurate TypeScript examples19- Employ functional, declarative programming while avoiding class-based approaches20- Prioritize iteration and modularization over code duplication21- Use descriptive variable names with auxiliary verbs (`isLoading`, `hasError`)22- Implement the RORO pattern (Receive an Object, Return an Object)2324### JavaScript/TypeScript Standards2526- Use `function` keyword for pure functions27- Omit semicolons28- Leverage TypeScript exclusively, preferring interfaces over types29- Structure files as: exported component, subcomponents, helpers, static content, types30- Minimize unnecessary curly braces in conditionals3132### Error Handling3334- Address errors and edge cases at function entry points35- Apply early returns for error conditions avoiding deep nesting36- Position the success path last for improved readability37- Use guard clauses for precondition validation38- Implement user-friendly error messaging3940## React and Next.js Guidelines4142- Use functional components with TypeScript interfaces43- Write declarative JSX using `function` declarations44- Style with Shadcn UI, Radix, and Tailwind CSS45- Implement mobile-first responsive design46- Minimize `use client`, `useEffect`, and `setState` - favor React Server Components47- Employ Zod for form validation48- Wrap client components in Suspense with fallbacks49- Use dynamic loading for non-critical components50- Optimize images (WebP format, size data, lazy loading)5152## Data and State Management5354- Leverage React Server Components for data fetching55- Implement the preload pattern to prevent waterfalls56- Use Supabase for real-time synchronization and state management57- Consider Vercel KV for chat history, rate limiting, and sessions5859## Supabase and GraphQL6061- Use Supabase client for database interactions and subscriptions62- Implement Row Level Security (RLS) policies63- Leverage Supabase Auth, Storage, and Edge Functions64- Use Genql for type-safe GraphQL API interactions65- Optimize GraphQL queries to fetch only necessary data6667## Styling and Testing6869### Styling7071- Apply Tailwind CSS utility-first approach72- Use Class Variance Authority (CVA) for component variants7374### Testing7576- Implement unit tests for utilities and hooks77- Create integration tests for complex components78- Develop end-to-end tests for critical user flows7980## Accessibility and Documentation8182### Accessibility8384- Ensure keyboard navigation throughout interfaces85- Implement proper ARIA labels and semantic roles86- Maintain WCAG-compliant color contrast ratios8788### Documentation8990- Provide clear JSDoc comments for IDE intellisense91- Document Supabase schemas, RLS policies, and Edge Functions