# React Best Practices > React best-practices reviewer for TSX files. Triggers after editing multiple TSX components to run a condensed quality checklist covering component structure, hooks usage, accessibility, performance, and TypeScript patterns. Fuente: https://skillsagentes.com/skills/vercel/vercel-plugin/react-best-practices Markdown: https://skillsagentes.com/skills/vercel/vercel-plugin/react-best-practices.md Repositorio: https://github.com/vercel/vercel-plugin Autor: vercel Licencia: NOASSERTION Actualizado: hace 5 meses Coste de contexto: 56 tok instalada, 2k tok al activarse, 50.9k tok con todos los archivos del bundle Bundle: 69 archivos, 199 KB Permisos que pide: ninguno declarado ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add vercel/vercel-plugin --skill react-best-practices --agent claude-code # Cursor npx -y skills add vercel/vercel-plugin --skill react-best-practices --agent cursor # Codex npx -y skills add vercel/vercel-plugin --skill react-best-practices --agent codex # Gemini CLI npx -y skills add vercel/vercel-plugin --skill react-best-practices --agent gemini # Windsurf npx -y skills add vercel/vercel-plugin --skill react-best-practices --agent windsurf # Cline npx -y skills add vercel/vercel-plugin --skill react-best-practices --agent cline ``` ## Archivos - AGENTS.md — 92 KB - SKILL.md — 8 KB - overlay.yaml — 2 KB - rules/_sections.md — 2 KB - rules/_template.md — 631 B - rules/advanced-event-handler-refs.md — 1 KB - rules/advanced-init-once.md — 958 B - rules/advanced-use-latest.md — 1 KB - rules/async-api-routes.md — 1 KB - rules/async-defer-await.md — 2 KB - rules/async-dependencies.md — 1 KB - rules/async-parallel.md — 654 B - rules/async-suspense-boundaries.md — 2 KB - rules/bundle-barrel-imports.md — 2 KB - rules/bundle-conditional.md — 949 B - rules/bundle-defer-third-party.md — 920 B - rules/bundle-dynamic-imports.md — 791 B - rules/bundle-preload.md — 1 KB - rules/client-event-listeners.md — 2 KB - rules/client-localstorage-schema.md — 2 KB - rules/client-passive-event-listeners.md — 2 KB - rules/client-swr-dedup.md — 1 KB - rules/js-batch-dom-css.md — 3 KB - rules/js-cache-function-results.md — 2 KB - rules/js-cache-property-access.md — 532 B - rules/js-cache-storage.md — 2 KB - rules/js-combine-iterations.md — 753 B - rules/js-early-exit.md — 1 KB - rules/js-flatmap-filter.md — 1 KB - rules/js-hoist-regexp.md — 1 KB - rules/js-index-maps.md — 837 B - rules/js-length-check-first.md — 2 KB - rules/js-min-max-loop.md — 2 KB - rules/js-set-map-lookups.md — 532 B - rules/js-tosorted-immutable.md — 2 KB - rules/rendering-activity.md — 564 B - rules/rendering-animate-svg-wrapper.md — 1 KB - rules/rendering-conditional-render.md — 980 B - rules/rendering-content-visibility.md — 815 B - rules/rendering-hoist-jsx.md — 1 KB - rules/rendering-hydration-no-flicker.md — 2 KB - rules/rendering-hydration-suppress-warning.md — 872 B - rules/rendering-resource-hints.md — 2 KB - rules/rendering-script-defer-async.md — 2 KB - rules/rendering-svg-precision.md — 588 B - rules/rendering-usetransition-loading.md — 2 KB - rules/rerender-defer-reads.md — 973 B - rules/rerender-dependencies.md — 824 B - rules/rerender-derived-state-no-effect.md — 1 KB - rules/rerender-derived-state.md — 728 B - rules/rerender-functional-setstate.md — 3 KB - rules/rerender-lazy-state-init.md — 2 KB - rules/rerender-memo-with-default-value.md — 1 KB - rules/rerender-memo.md — 1 KB - rules/rerender-move-effect-to-event.md — 1 KB - rules/rerender-no-inline-components.md — 2 KB - rules/rerender-simple-expression-in-memo.md — 1018 B - rules/rerender-split-combined-hooks.md — 2 KB - rules/rerender-transitions.md — 1 KB - rules/rerender-use-deferred-value.md — 2 KB - rules/rerender-use-ref-transient-values.md — 2 KB - rules/server-after-nonblocking.md — 2 KB - rules/server-auth-actions.md — 3 KB - rules/server-cache-lru.md — 1 KB - rules/server-cache-react.md — 2 KB - rules/server-dedup-props.md — 2 KB - rules/server-hoist-static-io.md — 4 KB - rules/server-parallel-fetching.md — 2 KB - rules/server-serialization.md — 996 B ## SKILL.md Reproducido tal cual desde vercel/vercel-plugin bajo NOASSERTION. Esta sección es el documento original y está en inglés. # Vercel React Best Practices Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 64 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation. ## When to Apply Reference these guidelines when: - Writing new React components or Next.js pages - Implementing data fetching (client or server-side) - Reviewing code for performance issues - Refactoring existing React/Next.js code - Optimizing bundle size or load times ## Rule Categories by Priority | Priority | Category | Impact | Prefix | |----------|----------|--------|--------| | 1 | Eliminating Waterfalls | CRITICAL | `async-` | | 2 | Bundle Size Optimization | CRITICAL | `bundle-` | | 3 | Server-Side Performance | HIGH | `server-` | | 4 | Client-Side Data Fetching | MEDIUM-HIGH | `client-` | | 5 | Re-render Optimization | MEDIUM | `rerender-` | | 6 | Rendering Performance | MEDIUM | `rendering-` | | 7 | JavaScript Performance | LOW-MEDIUM | `js-` | | 8 | Advanced Patterns | LOW | `advanced-` | ## Quick Reference ### 1. Eliminating Waterfalls (CRITICAL) - `async-defer-await` - Move await into branches where actually used - `async-parallel` - Use Promise.all() for independent operations - `async-dependencies` - Use better-all for partial dependencies - `async-api-routes` - Start promises early, await late in API routes - `async-suspense-boundaries` - Use Suspense to stream content ### 2. Bundle Size Optimization (CRITICAL) - `bundle-barrel-imports` - Import directly, avoid barrel files - `bundle-dynamic-imports` - Use next/dynamic for heavy components - `bundle-defer-third-party` - Load analytics/logging after hydration - `bundle-conditional` - Load modules only when feature is activated - `bundle-preload` - Preload on hover/focus for perceived speed ### 3. Server-Side Performance (HIGH) - `server-auth-actions` - Authenticate server actions like API routes - `server-cache-react` - Use React.cache() for per-request deduplication - `server-cache-lru` - Use LRU cache for cross-request caching - `server-dedup-props` - Avoid duplicate serialization in RSC props - `server-hoist-static-io` - Hoist static I/O (fonts, logos) to module level - `server-serialization` - Minimize data passed to client components - `server-parallel-fetching` - Restructure components to parallelize fetches - `server-after-nonblocking` - Use after() for non-blocking operations ### 4. Client-Side Data Fetching (MEDIUM-HIGH) - `client-swr-dedup` - Use SWR for automatic request deduplication - `client-event-listeners` - Deduplicate global event listeners - `client-passive-event-listeners` - Use passive listeners for scroll - `client-localstorage-schema` - Version and minimize localStorage data ### 5. Re-render Optimization (MEDIUM) - `rerender-defer-reads` - Don't subscribe to state only used in callbacks - `rerender-memo` - Extract expensive work into memoized components - `rerender-memo-with-default-value` - Hoist default non-primitive props - `rerender-dependencies` - Use primitive dependencies in effects - `rerender-derived-state` - Subscribe to derived booleans, not raw values - `rerender-derived-state-no-effect` - Derive state during render, not effects - `rerender-functional-setstate` - Use functional setState for stable callbacks - `rerender-lazy-state-init` - Pass function to useState for expensive values - `rerender-simple-expression-in-memo` - Avoid memo for simple primitives - `rerender-split-combined-hooks` - Split hooks with independent dependencies - `rerender-move-effect-to-event` - Put interaction logic in event handlers - `rerender-transitions` - Use startTransition for non-urgent updates - `rerender-use-deferred-value` - Defer expensive renders to keep input responsive - `rerender-use-ref-transient-values` - Use refs for transient frequent values - `rerender-no-inline-components` - Don't define components inside components ### 6. Rendering Performance (MEDIUM) - `rendering-animate-svg-wrapper` - Animate div wrapper, not SVG element - `rendering-content-visibility` - Use content-visibility for long lists - `rendering-hoist-jsx` - Extract static JSX outside components - `rendering-svg-precision` - Reduce SVG coordinate precision - `rendering-hydration-no-flicker` - Use inline script for client-only data - `rendering-hydration-suppress-warning` - Suppress expected mismatches - `rendering-activity` - Use Activity component for show/hide - `rendering-conditional-render` - Use ternary, not && for conditionals - `rendering-usetransition-loading` - Prefer useTransition for loading state - `rendering-resource-hints` - Use React DOM resource hints for preloading - `rendering-script-defer-async` - Use defer or async on script tags ### 7. JavaScript Performance (LOW-MEDIUM) - `js-batch-dom-css` - Group CSS changes via classes or cssText - `js-index-maps` - Build Map for repeated lookups - `js-cache-property-access` - Cache object properties in loops - `js-cache-function-results` - Cache function results in module-level Map - `js-cache-storage` - Cache localStorage/sessionStorage reads - `js-combine-iterations` - Combine multiple filter/map into one loop - `js-length-check-first` - Check array length before expensive comparison - `js-early-exit` - Return early from functions - `js-hoist-regexp` - Hoist RegExp creation outside loops - `js-min-max-loop` - Use loop for min/max instead of sort - `js-set-map-lookups` - Use Set/Map for O(1) lookups - `js-tosorted-immutable` - Use toSorted() for immutability - `js-flatmap-filter` - Use flatMap to map and filter in one pass ### 8. Advanced Patterns (LOW) - `advanced-event-handler-refs` - Store event handlers in refs - `advanced-init-once` - Initialize app once per app load - `advanced-use-latest` - useLatest for stable callback refs ## How to Use Read individual rule files for detailed explanations and code examples: ``` rules/async-parallel.md rules/bundle-barrel-imports.md ``` Each rule file contains: - Brief explanation of why it matters - Incorrect code example with explanation - Correct code example with explanation - Additional context and references ## Full Compiled Document For the complete guide with all rules expanded: `AGENTS.md` ## Dónde encaja - Categoría: [Herramientas para desarrolladores](https://skillsagentes.com/categorias/herramientas-desarrollo.md) — Skills que cambian cómo tu agente escribe, revisa y despliega código. - Creador: [vercel](https://skillsagentes.com/creators/vercel.md) — 79 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [Knowledge Update](https://skillsagentes.com/skills/vercel/vercel-plugin/knowledge-update.md): Corrects outdated LLM knowledge about the Vercel platform and introduces new products. Injected at session start. - [Vercel Connect](https://skillsagentes.com/skills/vercel/vercel-plugin/vercel-connect.md): Vercel Connect expert guidance — securely obtain scoped OAuth tokens for third-party services (Slack, GitHub, MCP servers, OAuth, Snowflake) on behalf of apps or users via Vercel OIDC. Use when wiring up third-party API access, connecting to MCP servers, sending Slack messages, accessing GitHub APIs, receiving webhook events from Slack/Linear/GitHub and forwarding them to your agents and apps, or building eve agent connections. - [Vercel Functions](https://skillsagentes.com/skills/vercel/vercel-plugin/vercel-functions.md): Vercel Functions expert guidance — Serverless Functions, Edge Functions, Fluid Compute, streaming, Cron Jobs, and runtime configuration. Use when configuring, debugging, or optimizing server-side code running on Vercel. - [Cdn Caching](https://skillsagentes.com/skills/vercel/vercel-plugin/cdn-caching.md): Debug Vercel CDN caching — cache hit rate, stale content, revalidation behavior, ISR + PPR, per-request cache reasons (cacheReason) and PPR state (ppr_state), and costs. - [Eve](https://skillsagentes.com/skills/vercel/vercel-plugin/eve.md): eve framework guidance for durable AI agents and agent-powered applications. Use when creating, editing, or debugging an eve project, when the user explicitly asks for eve, or when the build-agents skill has selected eve as the default framework. Covers eve's filesystem-first runtime, durable sessions, tools, skills, connections, channels, sandboxes, subagents, schedules, evals, frontend clients, and Agent Runs observability. Do not use for incidental agent mentions, generic agent-building prompts, or established non-eve stacks unless the user asks for comparison or migration. ## Skills relacionadas - [Benchmark Sandbox](https://skillsagentes.com/skills/vercel/vercel-plugin/benchmark-sandbox.md): Run vercel-plugin eval scenarios in Vercel Sandboxes instead of local WezTerm panels. Provisions ephemeral microVMs with Claude Code + plugin pre-installed, runs benchmark prompts, extracts hook artifacts, and produces coverage reports. - [Release](https://skillsagentes.com/skills/vercel/vercel-plugin/release.md): Release vercel-plugin — run gates, bump version, generate artifacts, commit, and push. Use when asked to "release", "ship", "bump and push", or "cut a release". - [Access Protected Vercel Deployment](https://skillsagentes.com/skills/vercel/vercel-plugin/access-protected-vercel-deployment.md): Access and test Vercel deployments protected by Vercel Authentication, SSO, or Deployment Protection. Use when curl, agent-browser, Playwright, or another automated request reaches a Vercel login or protection page; when a protected preview or production URL returns 401 or 403; when TRUSTED_SOURCES_ENVIRONMENT_MISMATCH appears; or when choosing between `vercel curl` and the `x-vercel-trusted-oidc-idp-token` header. - [Ai Gateway](https://skillsagentes.com/skills/vercel/vercel-plugin/ai-gateway.md): Vercel AI Gateway expert guidance. Use when configuring model routing, provider failover, cost tracking, or managing multiple AI providers through a unified API. - [Ai Sdk](https://skillsagentes.com/skills/vercel/vercel-plugin/ai-sdk.md): Vercel AI SDK expert guidance. Use when building AI-powered features — chat interfaces, text generation, structured output, tool calling, agents, MCP integration, streaming, embeddings, reranking, image generation, or working with any LLM provider. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)