vercel-react-best-practices
React 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, bundle optimization, or performance improvements.
- License 许可
- MIT
- 最近更新
- 2026-05-02
- Stars
- ★ 3
- Forks
- 1
01 前言 Front Matter
- name
- vercel-react-best-practices
- license
- MIT
- metadata
- { "author": "vercel", "version": "1.0.0" }
- description
- React 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, bundle optimization, or performance improvements.
02 资源文件 52
- 参考文档AGENTS.md64.0 KB
- 参考文档references/patterns.md9.8 KB
- 参考文档references/sample-plan.md3.2 KB
- 参考文档rules/advanced-event-handler-refs.md1.4 KB
- 参考文档rules/advanced-use-latest.md1.2 KB
- 参考文档rules/async-api-routes.md1.1 KB
- 参考文档rules/async-defer-await.md2.0 KB
- 参考文档rules/async-dependencies.md942 B
- 参考文档rules/async-parallel.md654 B
- 参考文档rules/async-suspense-boundaries.md2.5 KB
- 参考文档rules/bundle-barrel-imports.md2.3 KB
- 参考文档rules/bundle-conditional.md949 B
- 参考文档rules/bundle-defer-third-party.md920 B
- 参考文档rules/bundle-dynamic-imports.md791 B
- 参考文档rules/bundle-preload.md1.1 KB
- 参考文档rules/client-event-listeners.md1.9 KB
- 参考文档rules/client-localstorage-schema.md1.9 KB
- 参考文档rules/client-passive-event-listeners.md1.6 KB
- 参考文档rules/client-swr-dedup.md1.1 KB
- 参考文档rules/js-batch-dom-css.md1.6 KB
- 参考文档rules/js-cache-function-results.md1.9 KB
- 参考文档rules/js-cache-property-access.md532 B
- 参考文档rules/js-cache-storage.md1.6 KB
- 参考文档rules/js-combine-iterations.md753 B
- 参考文档rules/js-early-exit.md1.1 KB
- 参考文档rules/js-hoist-regexp.md1.0 KB
- 参考文档rules/js-index-maps.md837 B
- 参考文档rules/js-length-check-first.md1.7 KB
- 参考文档rules/js-min-max-loop.md2.2 KB
- 参考文档rules/js-set-map-lookups.md532 B
- 参考文档rules/js-tosorted-immutable.md1.7 KB
- 参考文档rules/rendering-activity.md564 B
- 参考文档rules/rendering-animate-svg-wrapper.md1.2 KB
- 参考文档rules/rendering-conditional-render.md980 B
- 参考文档rules/rendering-content-visibility.md815 B
- 参考文档rules/rendering-hoist-jsx.md1.0 KB
- 参考文档rules/rendering-hydration-no-flicker.md2.3 KB
- 参考文档rules/rendering-svg-precision.md588 B
- 参考文档rules/rerender-defer-reads.md973 B
- 参考文档rules/rerender-dependencies.md824 B
- 参考文档rules/rerender-derived-state.md728 B
- 参考文档rules/rerender-functional-setstate.md2.9 KB
- 参考文档rules/rerender-lazy-state-init.md2.0 KB
- 参考文档rules/rerender-memo.md1.1 KB
- 参考文档rules/rerender-transitions.md1.0 KB
- 参考文档rules/server-after-nonblocking.md2.0 KB
- 参考文档rules/server-cache-lru.md1.3 KB
- 参考文档rules/server-cache-react.md2.2 KB
- 参考文档rules/server-parallel-fetching.md1.5 KB
- 参考文档rules/server-serialization.md996 B
- 脚本scripts/handle-deleted-modified.sh5.7 KB
- 脚本scripts/validate-conflicts.sh3.0 KB
03 SKILL.md 正文
Vercel React Best Practices
Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 45 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 usedasync-parallel- Use Promise.all() for independent operationsasync-dependencies- Use better-all for partial dependenciesasync-api-routes- Start promises early, await late in API routesasync-suspense-boundaries- Use Suspense to stream content
2. Bundle Size Optimization (CRITICAL)
bundle-barrel-imports- Import directly, avoid barrel filesbundle-dynamic-imports- Use next/dynamic for heavy componentsbundle-defer-third-party- Load analytics/logging after hydrationbundle-conditional- Load modules only when feature is activatedbundle-preload- Preload on hover/focus for perceived speed
3. Server-Side Performance (HIGH)
server-cache-react- Use React.cache() for per-request deduplicationserver-cache-lru- Use LRU cache for cross-request cachingserver-serialization- Minimize data passed to client componentsserver-parallel-fetching- Restructure components to parallelize fetchesserver-after-nonblocking- Use after() for non-blocking operations
4. Client-Side Data Fetching (MEDIUM-HIGH)
client-swr-dedup- Use SWR for automatic request deduplicationclient-event-listeners- Deduplicate global event listeners
5. Re-render Optimization (MEDIUM)
rerender-defer-reads- Don't subscribe to state only used in callbacksrerender-memo- Extract expensive work into memoized componentsrerender-dependencies- Use primitive dependencies in effectsrerender-derived-state- Subscribe to derived booleans, not raw valuesrerender-functional-setstate- Use functional setState for stable callbacksrerender-lazy-state-init- Pass function to useState for expensive valuesrerender-transitions- Use startTransition for non-urgent updates
6. Rendering Performance (MEDIUM)
rendering-animate-svg-wrapper- Animate div wrapper, not SVG elementrendering-content-visibility- Use content-visibility for long listsrendering-hoist-jsx- Extract static JSX outside componentsrendering-svg-precision- Reduce SVG coordinate precisionrendering-hydration-no-flicker- Use inline script for client-only datarendering-activity- Use Activity component for show/hiderendering-conditional-render- Use ternary, not && for conditionals
7. JavaScript Performance (LOW-MEDIUM)
js-batch-dom-css- Group CSS changes via classes or cssTextjs-index-maps- Build Map for repeated lookupsjs-cache-property-access- Cache object properties in loopsjs-cache-function-results- Cache function results in module-level Mapjs-cache-storage- Cache localStorage/sessionStorage readsjs-combine-iterations- Combine multiple filter/map into one loopjs-length-check-first- Check array length before expensive comparisonjs-early-exit- Return early from functionsjs-hoist-regexp- Hoist RegExp creation outside loopsjs-min-max-loop- Use loop for min/max instead of sortjs-set-map-lookups- Use Set/Map for O(1) lookupsjs-tosorted-immutable- Use toSorted() for immutability
8. Advanced Patterns (LOW)
advanced-event-handler-refs- Store event handlers in refsadvanced-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
rules/_sections.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
04 同仓库更多 Skills
zarr-python
Chunked N-D arrays for cloud storage. Compressed arrays, parallel I/O, S3/GCS integration, NumPy/Dask/Xarray compatible, for large-scale scientific computing pipelines.
zabbix
Zabbix monitoring system automation via API and Python. Use when: (1) Managing hosts, templates, items, triggers, or host groups, (2) Automating monitoring configuration, (3) Sending data via Zabbix trapper/sender, (4) Querying historical data or events, (5) Bulk operations on Zabbix objects, (6) Maintenance window management, (7) User/permission management
x-twitter-growth
X/Twitter growth engine for building audience, crafting viral content, and analyzing engagement. Use when the user wants to grow on X/Twitter, write tweets or threads, analyze their X profile, research competitors on X, plan a posting strategy, or optimize engagement. Complements social-content (generic multi-platform) with X-specific depth: algorithm mechanics, thread engineering, reply strategy, profile optimization, and competitive intelligence via web search.
what-if-oracle
Run structured What-If scenario analysis with multi-branch possibility exploration. Use this skill when the user asks speculative questions like "what if...", "what would happen if...", "what are the possibilities", "explore scenarios", "scenario analysis", "possibility space", "what could go wrong", "best case / worst case", "risk analysis", "contingency planning", "strategic options", or any question about uncertain futures. Also trigger when the user faces a fork-in-the-road decision, wants to stress-test an idea, or needs to think through consequences before committing.
venue-templates
Access comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
vaex
Use this skill for processing and analyzing large tabular datasets (billions of rows) that exceed available RAM. Vaex excels at out-of-core DataFrame operations, lazy evaluation, fast aggregations, efficient visualization of big data, and machine learning on large datasets. Apply when users need to work with large CSV/HDF5/Arrow/Parquet files, perform fast statistics on massive datasets, create visualizations of big data, or build ML pipelines that do not fit in memory.