$npx -y skills add vercel-labs/open-agents --skill vercel-react-best-practicesReact and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching,
| 1 | # Vercel React Best Practices |
| 2 | |
| 3 | Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 58 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation. |
| 4 | |
| 5 | ## When to Apply |
| 6 | |
| 7 | Reference these guidelines when: |
| 8 | - Writing new React components or Next.js pages |
| 9 | - Implementing data fetching (client or server-side) |
| 10 | - Reviewing code for performance issues |
| 11 | - Refactoring existing React/Next.js code |
| 12 | - Optimizing bundle size or load times |
| 13 | |
| 14 | ## Rule Categories by Priority |
| 15 | |
| 16 | | Priority | Category | Impact | Prefix | |
| 17 | |----------|----------|--------|--------| |
| 18 | | 1 | Eliminating Waterfalls | CRITICAL | `async-` | |
| 19 | | 2 | Bundle Size Optimization | CRITICAL | `bundle-` | |
| 20 | | 3 | Server-Side Performance | HIGH | `server-` | |
| 21 | | 4 | Client-Side Data Fetching | MEDIUM-HIGH | `client-` | |
| 22 | | 5 | Re-render Optimization | MEDIUM | `rerender-` | |
| 23 | | 6 | Rendering Performance | MEDIUM | `rendering-` | |
| 24 | | 7 | JavaScript Performance | LOW-MEDIUM | `js-` | |
| 25 | | 8 | Advanced Patterns | LOW | `advanced-` | |
| 26 | |
| 27 | ## Quick Reference |
| 28 | |
| 29 | ### 1. Eliminating Waterfalls (CRITICAL) |
| 30 | |
| 31 | - `async-defer-await` - Move await into branches where actually used |
| 32 | - `async-parallel` - Use Promise.all() for independent operations |
| 33 | - `async-dependencies` - Use better-all for partial dependencies |
| 34 | - `async-api-routes` - Start promises early, await late in API routes |
| 35 | - `async-suspense-boundaries` - Use Suspense to stream content |
| 36 | |
| 37 | ### 2. Bundle Size Optimization (CRITICAL) |
| 38 | |
| 39 | - `bundle-barrel-imports` - Import directly, avoid barrel files |
| 40 | - `bundle-dynamic-imports` - Use next/dynamic for heavy components |
| 41 | - `bundle-defer-third-party` - Load analytics/logging after hydration |
| 42 | - `bundle-conditional` - Load modules only when feature is activated |
| 43 | - `bundle-preload` - Preload on hover/focus for perceived speed |
| 44 | |
| 45 | ### 3. Server-Side Performance (HIGH) |
| 46 | |
| 47 | - `server-auth-actions` - Authenticate server actions like API routes |
| 48 | - `server-cache-react` - Use React.cache() for per-request deduplication |
| 49 | - `server-cache-lru` - Use LRU cache for cross-request caching |
| 50 | - `server-dedup-props` - Avoid duplicate serialization in RSC props |
| 51 | - `server-hoist-static-io` - Hoist static I/O (fonts, logos) to module level |
| 52 | - `server-serialization` - Minimize data passed to client components |
| 53 | - `server-parallel-fetching` - Restructure components to parallelize fetches |
| 54 | - `server-after-nonblocking` - Use after() for non-blocking operations |
| 55 | |
| 56 | ### 4. Client-Side Data Fetching (MEDIUM-HIGH) |
| 57 | |
| 58 | - `client-swr-dedup` - Use SWR for automatic request deduplication |
| 59 | - `client-event-listeners` - Deduplicate global event listeners |
| 60 | - `client-passive-event-listeners` - Use passive listeners for scroll |
| 61 | - `client-localstorage-schema` - Version and minimize localStorage data |
| 62 | |
| 63 | ### 5. Re-render Optimization (MEDIUM) |
| 64 | |
| 65 | - `rerender-defer-reads` - Don't subscribe to state only used in callbacks |
| 66 | - `rerender-memo` - Extract expensive work into memoized components |
| 67 | - `rerender-memo-with-default-value` - Hoist default non-primitive props |
| 68 | - `rerender-dependencies` - Use primitive dependencies in effects |
| 69 | - `rerender-derived-state` - Subscribe to derived booleans, not raw values |
| 70 | - `rerender-derived-state-no-effect` - Derive state during render, not effects |
| 71 | - `rerender-functional-setstate` - Use functional setState for stable callbacks |
| 72 | - `rerender-lazy-state-init` - Pass function to useState for expensive values |
| 73 | - `rerender-simple-expression-in-memo` - Avoid memo for simple primitives |
| 74 | - `rerender-move-effect-to-event` - Put interaction logic in event handlers |
| 75 | - `rerender-transitions` - Use startTransition for non-urgent updates |
| 76 | - `rerender-use-ref-transient-values` - Use refs for transient frequent values |
| 77 | |
| 78 | ### 6. Rendering Performance (MEDIUM) |
| 79 | |
| 80 | - `rendering-animate-svg-wrapper` - Animate div wrapper, not SVG element |
| 81 | - `rendering-content-visibility` - Use content-visibility for long lists |
| 82 | - `rendering-hoist-jsx` - Extract static JSX outside components |
| 83 | - `rendering-svg-precision` - Reduce SVG coordinate precision |
| 84 | - `rendering-hydration-no-flicker` - Use inline script for client-only data |
| 85 | - `rendering-hydration-suppress-warning` - Suppress expected mismatches |
| 86 | - `rendering-activity` - Use Activity component for show/hide |
| 87 | - `rendering-conditional-render` - Use ternary, not && for conditionals |
| 88 | - `rendering-usetransition-loading` - Prefer useTransition for loading state |
| 89 | |
| 90 | ### 7. JavaScript Performance (LOW-MEDIUM) |
| 91 | |
| 92 | - `js-batch-dom-css` - Group CSS changes via classes or cssText |
| 93 | - `js-index-maps` - Build Map for repeated lookups |
| 94 | - `js-cache-property- |