Loading...
Loading...
React and Next.js performance optimization guidelines from Vercel Engineering. Use 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.
npx skill4agent add supercent-io/skills-template vercel-react-best-practices| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Eliminating Waterfalls | CRITICAL | |
| 2 | Bundle Size Optimization | CRITICAL | |
| 3 | Server-Side Performance | HIGH | |
| 4 | Client-Side Data Fetching | MEDIUM-HIGH | |
| 5 | Re-render Optimization | MEDIUM | |
| 6 | Rendering Performance | MEDIUM | |
| 7 | JavaScript Performance | LOW-MEDIUM | |
| 8 | Advanced Patterns | LOW | |
async-defer-awaitasync-parallelasync-dependenciesasync-api-routesasync-suspense-boundariesbundle-barrel-importsbundle-dynamic-importsbundle-defer-third-partybundle-conditionalbundle-preloadserver-cache-reactserver-cache-lruserver-serializationserver-parallel-fetchingserver-after-nonblockingclient-swr-dedupclient-event-listenersrerender-defer-readsrerender-memorerender-dependenciesrerender-derived-statererender-functional-setstatererender-lazy-state-initrerender-transitionsrendering-animate-svg-wrapperrendering-content-visibilityrendering-hoist-jsxrendering-svg-precisionrendering-hydration-no-flickerrendering-activityrendering-conditional-renderjs-batch-dom-cssjs-index-mapsjs-cache-property-accessjs-cache-function-resultsjs-cache-storagejs-combine-iterationsjs-length-check-firstjs-early-exitjs-hoist-regexpjs-min-max-loopjs-set-map-lookupsjs-tosorted-immutableadvanced-event-handler-refsadvanced-use-latestAGENTS.md// ❌ Sequential: 3 round trips
const user = await fetchUser()
const posts = await fetchPosts()
const comments = await fetchComments()
// ✅ Parallel: 1 round trip
const [user, posts, comments] = await Promise.all([
fetchUser(),
fetchPosts(),
fetchComments()
])// ❌ Imports entire library (200-800ms import cost)
import { Check, X, Menu } from 'lucide-react'
// ✅ Imports only what you need
import Check from 'lucide-react/dist/esm/icons/check'
import X from 'lucide-react/dist/esm/icons/x'// ❌ Monaco bundles with main chunk ~300KB
import { MonacoEditor } from './monaco-editor'
// ✅ Monaco loads on demand
import dynamic from 'next/dynamic'
const MonacoEditor = dynamic(
() => import('./monaco-editor').then(m => m.MonacoEditor),
{ ssr: false }
)// ❌ Requires state as dependency, stale closure risk
const addItems = useCallback((newItems) => {
setItems([...items, ...newItems])
}, [items])
// ✅ Stable callback, no stale closures
const addItems = useCallback((newItems) => {
setItems(curr => [...curr, ...newItems])
}, [])#React#Next.js#performance#optimization#vercel#waterfalls#bundle-size#RSC#frontend