# Vercel React Best Practices > Pautas de optimización de rendimiento para React y Next.js del equipo de ingeniería de Vercel. Úsalo al escribir, revisar o refactorizar código React/Next.js. Fuente: https://skillsagentes.com/skills/calesthio/openmontage/vercel-react-best-practices Markdown: https://skillsagentes.com/skills/calesthio/openmontage/vercel-react-best-practices.md Repositorio: https://github.com/calesthio/OpenMontage Autor: calesthio Licencia: MIT Actualizado: el mes pasado Coste de contexto: 82 tok instalada, 1.8k tok al activarse, 53k tok con todos los archivos del bundle Bundle: 71 archivos, 207 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 calesthio/OpenMontage --skill vercel-react-best-practices --agent claude-code # Cursor npx -y skills add calesthio/OpenMontage --skill vercel-react-best-practices --agent cursor # Codex npx -y skills add calesthio/OpenMontage --skill vercel-react-best-practices --agent codex # Gemini CLI npx -y skills add calesthio/OpenMontage --skill vercel-react-best-practices --agent gemini # Windsurf npx -y skills add calesthio/OpenMontage --skill vercel-react-best-practices --agent windsurf # Cline npx -y skills add calesthio/OpenMontage --skill vercel-react-best-practices --agent cline ``` ## Qué hace - Recoge las pautas de rendimiento de React y Next.js del equipo de ingeniería de Vercel, ordenadas por prioridad - Críticas: eliminar cascadas de peticiones y optimizar el tamaño del bundle - Altas: rendimiento en servidor; medias-altas: obtención de datos en cliente - Medias: optimización de re-renderizados y de renderizado - Bajas-medias: rendimiento de JavaScript y patrones avanzados ## Cuándo usarla - Escribir componentes de React o páginas de Next.js nuevos - Implementar obtención de datos en cliente o en servidor - Revisar código buscando problemas de rendimiento - Optimizar tamaño de bundle o tiempos de carga ## Qué la activa - "Revisa el rendimiento de este componente" - "Tengo una cascada de peticiones, ¿cómo la elimino?" - "Reduce el tamaño del bundle de esta página" - "Optimiza los re-renderizados de esta lista" ## Archivos - AGENTS.md — 96 KB - README.md — 3 KB - SKILL.md — 7 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 — 3 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-request-idle-callback.md — 3 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-parallel-nested-fetching.md — 992 B - rules/server-serialization.md — 996 B ## SKILL.md Reproducido tal cual desde calesthio/OpenMontage bajo MIT. 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 65 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation. > **Extended reference:** [`AGENTS.md`](AGENTS.md) in this directory is the long-form upstream guide (vendored from Vercel). It is supplementary reference material scoped to this skill only — `SKILL.md` is the loadable entry point and the authority. It does not override or extend the repository-root `AGENTS.md` / `AGENT_GUIDE.md`. ## 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-parallel-nested-fetching` - Chain nested fetches per item in Promise.all - `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 - `js-request-idle-callback` - Defer non-critical work to browser idle time ### 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: [calesthio](https://skillsagentes.com/creators/calesthio.md) — 0 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 - [Seedance 2 5](https://skillsagentes.com/skills/calesthio/openmontage/seedance-2-5.md): Genera vídeo cinematográfico de 4-30 s con ByteDance Seedance 2.5 por fal.ai, Volcengine Ark, Runway o ComfyUI. Cubre el contrato de prompt 2.5, cortes duros, locks de continuidad y voz. - [Comfyui](https://skillsagentes.com/skills/calesthio/openmontage/comfyui.md): Úsalo al trabajar con workflows de ComfyUI en OpenMontage: comfyui_image/video/music, workflows propios, selección de output_node, modelos que faltan, LoRAs, poca VRAM e importación de workflows de la comunidad. - [Fish Audio Tts](https://skillsagentes.com/skills/calesthio/openmontage/fish-audio-tts.md): Genera narración expresiva y multilingüe con fish.audio (modelos S1 / S2) y reutiliza voces clonadas mediante reference_id. - [Minimax H3](https://skillsagentes.com/skills/calesthio/openmontage/minimax-h3.md): Genera vídeo con MiniMax H3 (Hailuo 3.0) por la API oficial v2, fal.ai, Runway, nodos partner de ComfyUI o pesos abiertos locales. Clips de 4-15s a 2K con animación de primer/último fotograma. - [Gemini Omni](https://skillsagentes.com/skills/calesthio/openmontage/gemini-omni.md): Genera y edita conversacionalmente vídeos cortos con Google Gemini Omni Flash: itera con ediciones en lenguaje natural, clips de 3-10s a 720p con audio y texto en pantalla, e imágenes de referencia por etiquetas. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)