Skip to content

sickn33/agentic-awesome-skills / plugins/aasb-web-app/skills/react-best-practices

react-best-practices

Verified

Comprehensive performance optimization guide for React and Next.js applications, adapted from Vercel’s published guidance. Use when writing new React components or Next.js pages, implementing data fetching (client or server-side), or reviewing code for performance issues.

FileKindSize
AGENTS.mdmarkdown56.3 KB
README.mdmarkdown1.1 KB
SKILL.mdskill md6.0 KB
metadata.jsonconfig641 B
rules/_sections.mdmarkdown1.5 KB
rules/_template.mdmarkdown631 B
rules/advanced-event-handler-refs.mdmarkdown1.7 KB
rules/advanced-use-latest.mdmarkdown1.4 KB
rules/async-api-routes.mdmarkdown1.4 KB
rules/async-defer-await.mdmarkdown2.2 KB
rules/async-dependencies.mdmarkdown1.1 KB
rules/async-parallel.mdmarkdown874 B
rules/async-suspense-boundaries.mdmarkdown2.7 KB
rules/bundle-barrel-imports.mdmarkdown1012 B
rules/bundle-conditional.mdmarkdown1014 B
rules/bundle-defer-third-party.mdmarkdown1.1 KB
rules/bundle-dynamic-imports.mdmarkdown1.0 KB
rules/bundle-preload.mdmarkdown1.4 KB
rules/client-event-listeners.mdmarkdown2.1 KB
rules/client-swr-dedup.mdmarkdown1.4 KB
rules/js-batch-dom-css.mdmarkdown2.2 KB
rules/js-cache-function-results.mdmarkdown1.8 KB
rules/js-cache-property-access.mdmarkdown638 B
rules/js-cache-storage.mdmarkdown2.0 KB
rules/js-combine-iterations.mdmarkdown753 B
rules/js-early-exit.mdmarkdown1.2 KB
rules/js-hoist-regexp.mdmarkdown1.2 KB
rules/js-index-maps.mdmarkdown1.0 KB
rules/js-length-check-first.mdmarkdown1.7 KB
rules/js-min-max-loop.mdmarkdown2.1 KB
rules/js-set-map-lookups.mdmarkdown532 B
rules/js-tosorted-immutable.mdmarkdown1.9 KB
rules/rendering-activity.mdmarkdown819 B
rules/rendering-animate-svg-wrapper.mdmarkdown1.3 KB
rules/rendering-conditional-render.mdmarkdown980 B
rules/rendering-content-visibility.mdmarkdown1.0 KB
rules/rendering-hoist-jsx.mdmarkdown1.0 KB
rules/rendering-hydration-no-flicker.mdmarkdown1.5 KB
rules/rendering-svg-precision.mdmarkdown794 B
rules/rerender-defer-reads.mdmarkdown973 B
rules/rerender-dependencies.mdmarkdown824 B
rules/rerender-derived-state.mdmarkdown724 B
rules/rerender-functional-setstate.mdmarkdown3.1 KB
rules/rerender-lazy-state-init.mdmarkdown2.4 KB
rules/rerender-memo.mdmarkdown1.3 KB
rules/rerender-transitions.mdmarkdown1.3 KB
rules/server-after-nonblocking.mdmarkdown2.2 KB
rules/server-cache-lru.mdmarkdown1.7 KB
rules/server-cache-react.mdmarkdown899 B
rules/server-parallel-fetching.mdmarkdown1.7 KB
rules/server-serialization.mdmarkdown1.3 KB

rules/server-parallel-fetching.md

View on GitHub
---
title: Parallel Data Fetching with Component Composition
impact: CRITICAL
impactDescription: eliminates server-side waterfalls
tags: server, rsc, parallel-fetching, composition
---

## Parallel Data Fetching with Component Composition

React Server Components execute sequentially within a tree. Restructure with composition to parallelize data fetching.

**Incorrect (Sidebar waits for Page's fetch to complete):**

```tsx
export default async function Page() {
  const header = await fetchHeader()
  return (
    <div>
      <div>{header}</div>
      <Sidebar />
    </div>
  )
}

async function Sidebar() {
  const items = await fetchSidebarItems()
  return <nav>{items.map(renderItem)}</nav>
}
```

**Correct (both fetch simultaneously):**

```tsx
async function Header() {
  const data = await fetchHeader()
  return <div>{data}</div>
}

async function Sidebar() {
  const items = await fetchSidebarItems()
  return <nav>{items.map(renderItem)}</nav>
}

export default function Page() {
  return (
    <div>
      <Header />
      <Sidebar />
    </div>
  )
}
```

**Alternative with children prop:**

```tsx
async function Layout({ children }: { children: ReactNode }) {
  const header = await fetchHeader()
  return (
    <div>
      <div>{header}</div>
      {children}
    </div>
  )
}

async function Sidebar() {
  const items = await fetchSidebarItems()
  return <nav>{items.map(renderItem)}</nav>
}

export default function Page() {
  return (
    <Layout>
      <Sidebar />
    </Layout>
  )
}
```

The waterfall here comes from awaiting a parent fetch before returning its child, not a rule that all Server Components always execute sequentially. Composition and streaming behavior depend on the framework; verify timing.
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall