vercel-react-best-practices
This skill provides 70 React and Next.js performance optimization rules across 8 categories, prioritized by impact.
Identity proven by GitHub's verified organisation badge (sanity-io)
- Agents
- Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
- License
- MIT (permissive)
- Pin
- a80a997pinned Oct 9, 2026
- Context cost
- about 1,800 tokenswhen the skill loads
- GitHub stars
- 20on sanity-io/plugins
- Scripts
- None found
What it does
“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.”
Generated summary from the skill's own text
This skill provides 70 React and Next.js performance optimization rules across 8 categories, prioritized by impact. It guides agents on eliminating waterfalls, optimizing bundle size, improving server and client performance, and reducing re-renders through specific patterns and code examples.
When to use it
- Writing or refactoring React components and Next.js pages
- Optimizing bundle size, load times, or data fetching patterns
- Reviewing code for performance issues or anti-patterns
- Implementing server actions, client-side caching, or rendering strategies
When not to
- Building non-React applications or frontend frameworks
- When performance is not a concern or primary objective
- Addressing architectural decisions beyond code optimization
Install
These commands install from the publisher's repository and need no account.
skills CLI
npx skills add sanity-io/plugins --skill vercel-react-best-practicesInstalls from the repository's default branch, which may have changed since the commit we checked.
GitHub CLI 2.90 or later
gh skill install sanity-io/plugins vercel-react-best-practices@a80a997e3d11d188f9639ac3efab1d8f93a276efInstalls the commit we checked (a80a997).
Copy by hand
Download the folder at a80a997 and put it in .claude/skills/vercel-react-best-practices for Claude Code and in .agents/skills/vercel-react-best-practices for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.
Claude Code plugin
/plugin install sanity@claude-plugins-officialThe publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.
Copy for your agent
A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.
Prompt
Install the agent skill "vercel-react-best-practices" by Sanity. Source, pinned to commit a80a997e3d11d188f9639ac3efab1d8f93a276ef: https://github.com/sanity-io/plugins/tree/a80a997e3d11d188f9639ac3efab1d8f93a276ef/.agents/skills/vercel-react-best-practices 1. Download that folder at exactly this commit. Do not use the default branch. 2. Copy every file unchanged, keeping the folder structure, into .claude/skills/vercel-react-best-practices/ for Claude Code and .agents/skills/vercel-react-best-practices/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist. 3. Do not edit the files, and do not run any script in the folder unless I ask you to. 4. When you are done, list the files you copied and where you put them. Listing and checks: https://www.agentnative.dev/skills/sanity/vercel-react-best-practices
SKILL.md at the pin
--- name: vercel-react-best-practices 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. license: MIT metadata: author: vercel version: '1.0.0' --- # Vercel React Best Practices Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 70 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-cheap-condition-before-await` - Check cheap sync conditions before awaiting flags or remote values - `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-analyzable-paths` - Prefer statically analyzable import and file-system paths to avoid broad bundles and traces - `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-no-shared-module-state` - Avoid module-level mutable request state in RSC/SSR - `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-effect-event-deps` - Don't put `useEffectEvent` results in effect deps - `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`
From sanity-io/plugins at a80a997, shown as plain text under its license: MIT (permissive). The license text is in .agents/skills/vercel-react-best-practices/SKILL.md.
View SKILL.md on GitHub at a80a997Files
- SKILL.md7.4 KB · d951fc0e8155
- AGENTS.md108 KB · a2778854c9ef
- README.md3.4 KB · 3e655903c32e
- rules/
- _sections.md1.6 KB · 01c59969e4e8
- _template.md631 B · 99df2a3ea088
- advanced-effect-event-deps.md1.8 KB · 4d3715b40255
- advanced-event-handler-refs.md1.5 KB · 13496a59f0f2
- advanced-init-once.md958 B · 3e4dc22173eb
- advanced-use-latest.md1.1 KB · c115760625fc
- async-api-routes.md1.1 KB · ef4dbb68c3b9
- async-cheap-condition-before-await.md1.2 KB · 03107c1f70a2
- async-defer-await.md2.2 KB · 071bb14f6107
- async-dependencies.md1.3 KB · b698f6e4a3c8
- async-parallel.md646 B · 012a30bd3447
- async-suspense-boundaries.md2.5 KB · 1a561dabbdc2
- bundle-analyzable-paths.md2.4 KB · e9d7d8b81b48
- bundle-barrel-imports.md2.8 KB · 3b3be202b513
- bundle-conditional.md959 B · a5a9e930ea5c
- bundle-defer-third-party.md913 B · 703d4a1c0e54
- bundle-dynamic-imports.md780 B · d416eaf8febc
- bundle-preload.md1.1 KB · d789f7e30ea9
- client-event-listeners.md2.0 KB · bc2eb03c03c7
- client-localstorage-schema.md2.0 KB · 1b51a076745f
- client-passive-event-listeners.md1.6 KB · 95539c981635
- client-swr-dedup.md1.2 KB · f02956c64e4e
- js-batch-dom-css.md3.2 KB · 0d2b8b8f66ca
- js-cache-function-results.md1.9 KB · 08d12e0b7340
- js-cache-property-access.md532 B · 73e47431e748
- js-cache-storage.md1.6 KB · cd1298e3492a
- js-combine-iterations.md759 B · b3ab8de50367
- js-early-exit.md1.1 KB · a5cef0219aa4
- js-flatmap-filter.md1.4 KB · ad6e12eb5c36
- js-hoist-regexp.md1.0 KB · 11c98b374847
- js-index-maps.md847 B · bd8acd340c4c
- js-length-check-first.md1.7 KB · f6dd556147f6
- js-min-max-loop.md2.3 KB · f4ff5511d49d
- js-request-idle-callback.md2.6 KB · 8c5890495527
- js-set-map-lookups.md532 B · a7fd781a6ba9
- js-tosorted-immutable.md1.8 KB · d0a5e1b0fec4
- rendering-activity.md560 B · 5c3298cf75f7
- rendering-animate-svg-wrapper.md1.1 KB · 428b9dc83be3
- rendering-conditional-render.md928 B · 9640534f3010
- rendering-content-visibility.md813 B · 0c32222d524e
- rendering-hoist-jsx.md989 B · 5a129602e93c
- rendering-hydration-no-flicker.md2.2 KB · fa396b26f8c0
- rendering-hydration-suppress-warning.md850 B · fb6274dc927f
- rendering-resource-hints.md2.7 KB · 3c5ddda33f65
- rendering-script-defer-async.md1.9 KB · 4cea07b7875b
- rendering-svg-precision.md588 B · ed468533f6e9
- rendering-usetransition-loading.md2.1 KB · bb7829fe6b17
- rerender-defer-reads.md961 B · 98b3dc7ede97
- rerender-dependencies.md824 B · 17eb5830956f
- rerender-derived-state-no-effect.md1.2 KB · cb11ec76f50a
- rerender-derived-state.md727 B · 3a0e1a6cfb6e
- rerender-functional-setstate.md3.0 KB · 31122857688c
- rerender-lazy-state-init.md2.0 KB · ecc0928cdc19
- rerender-memo-with-default-value.md1.2 KB · 97044a6c3097
- rerender-memo.md1.1 KB · 16a1d24c378b
- rerender-move-effect-to-event.md1.3 KB · abc2cbf167be
- rerender-no-inline-components.md2.1 KB · e6b9c6b7fc88
- rerender-simple-expression-in-memo.md1.0 KB · ca98973e64a6
- rerender-split-combined-hooks.md1.8 KB · 16bb5a81b25f
- rerender-transitions.md1.0 KB · cb75c614e337
- rerender-use-deferred-value.md1.8 KB · e029cc9442fe
- rerender-use-ref-transient-values.md1.7 KB · f1a649af9d1d
- server-after-nonblocking.md2.0 KB · 7ddd06c3c228
- server-auth-actions.md2.6 KB · 1edc82d04e59
- server-cache-lru.md1.3 KB · bc65304e2539
- server-cache-react.md2.2 KB · 20ea6f4a155e
- server-dedup-props.md2.1 KB · 061cd37f0da2
- server-hoist-static-io.md4.4 KB · e81a56e48fe9
- server-no-shared-module-state.md1.8 KB · c50e91ed200e
- server-parallel-fetching.md1.6 KB · 701f53759d70
- server-parallel-nested-fetching.md993 B · 859fb12a10bb
- server-serialization.md992 B · 1093a2b11900
75 files, 228 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.
Skill folder on GitHub at a80a997More from Sanity
sanity-live-cache-components
Integrates Sanity Live with Next.js Cache Components in next-sanity v13+ apps, setting up shared cached data fetching through sanityFetch, live content…
Claude Code, Codex, Cursor +4 · about 4K tokens · pinned 6 days ago
content-experimentation-best-practices
This skill provides guidance for designing and running content experiments using A/B and multivariate testing.
Claude Code, Codex, Cursor +4 · about 360 tokens · pinned 6 days ago
content-modeling-best-practices
Guides agents through structured content modeling principles for headless CMSes like Sanity, covering schema design, content reuse strategies, and field…
Claude Code, Codex, Cursor +4 · about 340 tokens · pinned 6 days ago
portable-text-conversion
Converts HTML and Markdown content into Portable Text blocks for Sanity using markdownToPortableText, htmlToBlocks, or manual construction.
Claude Code, Codex, Cursor +4 · about 510 tokens · pinned 6 days ago
portable-text-serialization
This skill enables rendering Portable Text content across multiple frameworks and output formats using the @portabletext library family.
Claude Code, Codex, Cursor +4 · about 940 tokens · pinned 6 days ago
sanity-best-practices
This skill provides best practices for Sanity headless CMS development across schema design, GROQ queries, framework integrations (Next.js, Nuxt, Astro…
Claude Code, Codex, Cursor +4 · about 1.1K tokens · pinned 6 days ago
Related in Frontend and design
react-best-practices
This skill reviews React and TSX components against 70 best-practice rules organized by performance impact, checking for issues in async patterns, bundle…
by VercelOfficial publisher
Claude Code, Codex, Cursor +3 · about 1.7K tokens · pinned 6 days ago
next-bundle-optimizer
Audits Next.js applications to identify and reduce browser bundle size and initial-load work by analyzing routes, dependencies and client outputs.
by VercelOfficial publisher
Claude Code, Codex, Cursor +4 · about 2.3K tokens · pinned 6 days ago
next-cache-components-optimizer
Optimize Next.js routes to display meaningful UI instantly on initial load or client navigation by encoding the optimization goal as a failing…
by VercelOfficial publisher
Claude Code, Codex, Cursor +4 · about 5.6K tokens · pinned 6 days ago
next-partial-prefetching-adoption
Enables Partial Prefetching in Next.js 16.3+ apps and guides adoption through auditing Link prefetch behavior, preserving UI in tests or manually, and…
by VercelOfficial publisher
Claude Code, Codex, Cursor +4 · about 6.7K tokens · pinned 6 days ago
react-email
React Email lets agents build HTML email templates as React components and render them to HTML or plain text.
by ResendOfficial publisher
Claude Code, Codex, Cursor +4 · about 3.4K tokens · pinned 6 days ago
apollo-client
This skill guides building React applications with Apollo Client 4.x for managing GraphQL queries, mutations, and state.
by Apollo GraphQLOfficial publisher
Claude Code, Codex, Cursor +4 · about 1.7K tokens · pinned 6 days ago