101-react-patterns — Claude Code rule: React component patterns
101-react-patterns — a rule for React components: functional components, hooks for logic, Server Components by default.
MIT ★ 97 updated 2026-06-11
.cursor/rules/101-react-patterns.mdcWhat 101-react-patterns does
The rule defines React component structure in .tsx and .jsx: functional components only, Server Components by default (Client Components where interactivity is needed), business logic extracted to hooks or service layer. Limit is 200 lines per file. For state: local — useState/useReducer, server — React Query or SWR, global — Zustand, URL — nuqs or searchParams.
Performance: React.memo() only after measuring, lazy load heavy components with React.lazy() and Suspense, optimistic updates for UX. Requires Error Boundaries for fault isolation, loading/error/empty states for async data, semantic HTML and ARIA labels for accessibility. All interactive elements must support keyboard navigation.
What it helps with
- define React component structure: functional, Server Components, hooks
- choose state libraries: React Query, Zustand, nuqs
- set performance patterns: memo, lazy, optimistic updates
- require Error Boundaries and loading/error states
- enforce accessibility: semantic HTML, ARIA, keyboard support
Example prompts for the agent
- Rewrite
UserProfile.tsxfollowing React pattern rules - Extract logic from
Dashboard.tsxinto hooks per the rules - Add Error Boundary and loading states to
ProductList.tsx
How to install 101-react-patterns
Manually: put the files in place
.cursor/rules/101-react-patterns.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/101-react-patterns.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/101-react-patterns.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/101-react-patterns.mdManually: put the files in place
.clinerules/101-react-patterns.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about 101-react-patterns
How to install 101-react-patterns in Claude Code?
Place the rule file at .claude/rules/101-react-patterns.md.
What does the 101-react-patterns rule do?
Defines React component patterns: functional components, Server Components by default, hooks for logic, state library choices, performance and accessibility requirements.
When does 101-react-patterns use Client Components?
Only where client-side interactivity is needed. The rule defaults to Server Components.
Source text
101-react-patterns.mdc · MIT
---
description: React/JSX/TSX component patterns and conventions
globs: ["**/*.tsx", "**/*.jsx"]
alwaysApply: false
---
# React Patterns
## Component Structure
- Functional components only (no class components)
- Server Components by default; Client Components ('use client') only when needed
- Extract business logic into custom hooks or service layer
- Max 200 lines per component file
## State Management
- Local state: useState/useReducer
- Server state: React Query / SWR
- Global state: Zustand (or specified alternative)
- URL state: nuqs or searchParams
## Performance
- Use React.memo() only with measured performance issues
- Implement proper key props for lists
- Lazy load heavy components with React.lazy() + Suspense
- Use optimistic updates for better UX
## Error Handling
- Implement Error Boundaries for fault isolation
- Use proper loading/error/empty states for async data
- Never swallow errors silently
## Accessibility
- All interactive elements need keyboard support
- Use semantic HTML elements
- Include proper ARIA labels where needed
© obviousworks · MIT · obviousworks/vibe-coding-ai-rules