react-best-practices
Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Use when writing new React components or Next.js pages, implementing data fetching (client or server-side), or reviewing code for performance issues.
link
/skills/sickn33/react-best-practices/
Files
- manifest.json
- AGENTS.md
- README.md
- SKILL.md
- rules/_sections.md
- rules/_template.md
- rules/advanced-event-handler-refs.md
- rules/advanced-use-latest.md
- rules/async-api-routes.md
- rules/async-defer-await.md
- rules/async-dependencies.md
- rules/async-parallel.md
- rules/async-suspense-boundaries.md
- rules/bundle-barrel-imports.md
- rules/bundle-conditional.md
- rules/bundle-defer-third-party.md
- rules/bundle-dynamic-imports.md
- rules/bundle-preload.md
- rules/client-event-listeners.md
- rules/client-swr-dedup.md
- rules/js-batch-dom-css.md
- rules/js-cache-function-results.md
- rules/js-cache-property-access.md
- rules/js-cache-storage.md
- rules/js-combine-iterations.md
- rules/js-early-exit.md
- rules/js-hoist-regexp.md
- rules/js-index-maps.md
- rules/js-length-check-first.md
- rules/js-min-max-loop.md
- rules/js-set-map-lookups.md
- rules/js-tosorted-immutable.md
- rules/rendering-activity.md
- rules/rendering-animate-svg-wrapper.md
- rules/rendering-conditional-render.md
- rules/rendering-content-visibility.md
- rules/rendering-hoist-jsx.md
- rules/rendering-hydration-no-flicker.md
- rules/rendering-svg-precision.md
- rules/rerender-defer-reads.md
- rules/rerender-dependencies.md
- rules/rerender-derived-state.md
- rules/rerender-functional-setstate.md
- rules/rerender-lazy-state-init.md
- rules/rerender-memo.md
- rules/rerender-transitions.md
- rules/server-after-nonblocking.md
- rules/server-cache-lru.md
- rules/server-cache-react.md
- rules/server-parallel-fetching.md
- rules/server-serialization.md
SKILL.md
# React Best Practices
A structured repository for creating and maintaining React Best Practices optimized for agents and LLMs.
## Structure
- `rules/` - Individual rule files (one per rule)
- `_sections.md` - Section metadata (titles, impacts, descriptions)
- `_template.md` - Template for creating new rules
- `area-description.md` - Individual rule files
- `src/` - Build scripts and utilities
- `metadata.json` - Document metadata (version, organization, abstract)
- __`AGENTS.md`__ - Compiled output (generated)
- __`test-cases.json`__ - Test cases for LLM evaluation (generated)
## Getting Started
1. Install dependencies:
```bash
pnpm install
```
2. Build AGENTS.md from rules:
```bash
pnpm build
```
3. Validate rule files:
```bash
pnpm validate
```
4. Extract test cases:
```bash
pnpm extract-tests
```
## Creating a New Rule
1. Copy `rules/_template.md` to `rules/area-description.md`
2. Choose the appropriate area prefix:
- `async-` for Eliminating Waterfalls (Section 1)
- `bundle-` for Bundle Size Optimization (Section 2)
- `server-` for Server-Side Performance (Section 3)
- `client-` for Client-Side Data Fetching (Section 4)
- `rerender-` for Re-render Optimization (Section 5)
- `rendering-` for Rendering Performance (Section 6)
- `js-` for JavaScript Performance (Section 7)
- `advanced-` for Advanced Patterns (Section 8)
3. Fill in the frontmatter and content
4. Ensure you have clear examples with explanations
5. Run `pnpm build` to regenerate AGENTS.md and test-cases.json
## Rule File Structure
Each rule file should follow this structure:
```markdown
---
title: Rule Title Here
impact: MEDIUM
impactDescription: Optional description
tags: tag1, tag2, tag3
---
## Rule Title Here
Brief explanation of the rule and why it matters.
**Incorrect (description of what's wrong):**
```typescript
// Bad code example
```
**Correct (description of what's right):**
```typescript
// Good code example
```
Optional explanatory text after examples.
Reference: [Link](https://example.com)
## File Naming Convention
- Files starting with `_` are special (excluded from build)
- Rule files: `area-description.md` (e.g., `async-parallel.md`)
- Section is automatically inferred from filename prefix
- Rules are sorted alphabetically by title within each section
- IDs (e.g., 1.1, 1.2) are auto-generated during build
## Impact Levels
- `CRITICAL` - Highest priority, major performance gains
- `HIGH` - Significant performance improvements
- `MEDIUM-HIGH` - Moderate-high gains
- `MEDIUM` - Moderate performance improvements
- `LOW-MEDIUM` - Low-medium gains
- `LOW` - Incremental improvements
## Scripts
- `pnpm build` - Compile rules into AGENTS.md
- `pnpm validate` - Validate all rule files
- `pnpm extract-tests` - Extract test cases for LLM evaluation
- `pnpm dev` - Build and validate
## Contributing
When adding or modifying rules:
1. Use the correct filename prefix for your section
2. Follow the `_template.md` structure
3. Include clear bad/good examples with explanations
4. Add appropriate tags
5. Run `pnpm build` to regenerate AGENTS.md and test-cases.json
6. Rules are automatically sorted by title - no need to manage numbers!
## Acknowledgments
Originally created by [@shuding](https://x.com/shuding) at [Vercel](https://vercel.com).