Communitygithub.com

ComeOnOliver/skillshub

来自 Vercel 工程团队的 React 和 Next.js 性能优化指南。在编写、审查或重构 React/Next.js 代码时使用此技能,以确保采用最佳性能模式。触发条件包括涉及 React 组件、Next.js 页面、数据获取、包优化或性能改进的任务。

skillshub 是什么?

此技能由 Vercel 维护,是一个全面的 React 和 Next.js 性能优化指南,包含 8 个类别中的 45 条规则,并根据影响优先级排列。它涵盖了消除瀑布请求、包大小优化、服务器端性能、客户端数据获取、重新渲染优化、渲染性能、JavaScript 性能以及高级模式。该技能适用于编写新组件、实现数据获取、代码审查、重构现有代码以及优化包大小或加载时间。通过详细解释和代码示例,用户可以获得具体指导,以自动化的方式重构和生成代码。支持在 React 和 Next.js 应用中直接引用。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/jarrodwatts/claude-code-config/vercel-react-best-practices

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Vercel React 最佳实践

React 和 Next.js 应用的全面性能优化指南,由 Vercel 维护。包含 8 个类别的 45 条规则,按影响优先级排序,以指导自动化的重构和代码生成。

何时应用

在以下情况下参考这些指南:

  • 编写新的 React 组件或 Next.js 页面
  • 实现数据获取(客户端或服务器端)
  • 审查代码是否存在性能问题
  • 重构现有的 React/Next.js 代码
  • 优化包大小或加载时间

按优先级排序的规则类别

优先级类别影响前缀
1消除瀑布请求关键async-
2包大小优化关键bundle-
3服务器端性能高server-
4客户端数据获取中高client-
5重新渲染优化中rerender-
6渲染性能中rendering-
7JavaScript 性能低-中js-
8高级模式低advanced-

快速参考

1. 消除瀑布请求(关键)

  • async-defer-await - 将 await 移动到实际使用的分支中
  • async-parallel - 对独立操作使用 Promise.all()
  • async-dependencies - 对部分依赖使用 better-all
  • async-api-routes - 在 API 路由中尽早启动 Promise,延迟 await
  • async-suspense-boundaries - 使用 Suspense 流式传输内容

2. 包大小优化(关键)

  • bundle-barrel-imports - 直接导入,避免使用 barrel 文件
  • bundle-dynamic-imports - 对重型组件使用 next/dynamic
  • bundle-defer-third-party - 在水合后加载分析/日志记录
  • bundle-conditional - 仅在功能激活时加载模块
  • bundle-preload - 在悬停/焦点时预加载以提高感知速度

3. 服务器端性能(高)

  • server-cache-react - 使用 React.cache() 进行按请求去重
  • server-cache-lru - 使用 LRU 缓存进行跨请求缓存
  • server-serialization - 最小化传递给客户端组件的数据
  • server-parallel-fetching - 重构组件以并行化获取操作
  • server-after-nonblocking - 对非阻塞操作使用 after()

4. 客户端数据获取(中高)

  • client-swr-dedup - 使用 SWR 进行自动请求去重
  • client-event-listeners - 去重全局事件监听器

5. 重新渲染优化(中)

  • rerender-defer-reads - 不要订阅仅在回调中使用的状态
  • rerender-memo - 将昂贵的工作提取到记忆化的组件中
  • rerender-dependencies - 在副作用中使用原始依赖项
  • rerender-derived-state - 订阅派生的布尔值,而不是原始值
  • rerender-functional-setstate - 使用函数式 setState 以获得稳定的回调
  • rerender-lazy-state-init - 对昂贵的值将函数传递给 useState
  • rerender-transitions - 对非紧急更新使用 startTransition

6. 渲染性能(中)

  • rendering-animate-svg-wrapper - 动画化 div 包装器,而不是 SVG 元素
  • rendering-content-visibility - 对长列表使用 content-visibility
  • rendering-hoist-jsx - 将静态 JSX 提取到组件外部
  • rendering-svg-precision - 降低 SVG 坐标精度
  • rendering-hydration-no-flicker - 使用内联脚本处理客户端专用数据
  • rendering-activity - 使用 Activity 组件进行显示/隐藏
  • rendering-conditional-render - 使用三元运算符,而不是 && 进行条件渲染

7. JavaScript 性能(低-中)

  • js-batch-dom-css - 通过类或 cssText 分组 CSS 更改
  • js-index-maps - 为重复查找构建 Map
  • js-cache-property-access - 在循环中缓存对象属性
  • js-cache-function-results - 在模块级别的 Map 中缓存函数结果
  • js-cache-storage - 缓存 localStorage/sessionStorage 读取
  • js-combine-iterations - 将多个 filter/map 合并为一个循环
  • js-length-check-first - 在进行昂贵的比较之前检查数组长度
  • js-early-exit - 从函数中提前返回
  • js-hoist-regexp - 将 RegExp 创建提升到循环外部
  • js-min-max-loop - 使用循环查找最小/最大值,而不是排序
  • js-set-map-lookups - 使用 Set/Map 实现 O(1) 查找
  • js-tosorted-immutable - 使用 toSorted() 实现不可变性

8. 高级模式(低)

  • advanced-event-handler-refs - 将事件处理程序存储在 refs 中
  • advanced-use-latest - useLatest 用于稳定的回调 refs

如何使用

阅读单独的规则文件以获取详细的解释和代码示例:

rules/async-parallel.md
rules/bundle-barrel-imports.md
rules/_sections.md

每个规则文件包含:

  • 为什么重要的简要说明
  • 带有解释的错误代码示例
  • 带有解释的正确代码示例
  • 额外的上下文和参考

完整编译文档

有关所有规则扩展的完整指南:AGENTS.md

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

相关技能