Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Nextjs React Best Practices

ASecurity

Melhores práticas de performance para React e Next.js (App Router) — eliminar waterfalls, reduzir bundle, otimizar Server Components, data fetching, re-renders e Core Web Vitals. Use ao escrever ou revisar componentes React, páginas Next.js, data fetching (server ou client), ou ao investigar bundle size, hydration e lentidão de render.

3 stars
0 votes
0 copies
0 views
Added 9/20/2026
developmentjavascriptgojavareactnextjsnodeapifrontendfullstackperformance

Works with

cliapi

Security Analysis

A100/100

Scanned 9/20/2026

Install to Claude Code

$npx -y skills add joaoguirunas/team-os --skill nextjs-react-best-practices --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Nextjs React Best Practices?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Nextjs React Best Practices
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/joaoguirunas-nextjs-react-best-practices/badge)](https://www.skillsdirectory.com/skills/joaoguirunas-nextjs-react-best-practices)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: nextjs-react-best-practices
description: Melhores práticas de performance para React e Next.js (App Router) — eliminar waterfalls, reduzir bundle, otimizar Server Components, data fetching, re-renders e Core Web Vitals. Use ao escrever ou revisar componentes React, páginas Next.js, data fetching (server ou client), ou ao investigar bundle size, hydration e lentidão de render.
version: "1.0"
updated: "2026-08-26"
---

# Next.js + React Best Practices

Skill de performance para código React/Next.js, destilada das regras da engenharia da Vercel (70 regras em 8 categorias, priorizadas por impacto). Usada pelos implementers frontend e fullstack — **dev-dev-alpha, dev-dev-gamma, sites-dev-alpha, sites-dev-beta, sites-dev-gamma** — e pelos reviewers **dev-qa / sites-qa** em code review. Aplique na escrita de componentes novos, em refactors e em auditorias de bundle/render.

## 1. Eliminating Waterfalls (CRITICAL)

**1.1 — Parallelize independent async operations with `Promise.all()`.**

```tsx
// ❌ Sequential — 3 round trips
const user = await getUser(id)
const posts = await getPosts(id)
const stats = await getStats(id)

// ✅ Parallel — 1 round trip window
const [user, posts, stats] = await Promise.all([
  getUser(id), getPosts(id), getStats(id),
])
```

**1.2 — Check cheap conditions before awaiting.** Don't pay for a fetch you might discard.

```tsx
// ❌ fetch always runs
const data = await fetchExpensive()
if (!flag.enabled) return null

// ✅ bail out first
if (!flag.enabled) return null
const data = await fetchExpensive()
```

**1.3 — Move `await` into the branch that needs it.** If only one code path consumes the promise, await it there — start the promise early, await late.

**1.4 — Stream with Suspense instead of blocking the whole page.** Fetch fast data in the page; wrap slow sections in `<Suspense fallback={...}>` and let them stream in.

```tsx
export default async function Page() {
  const header = await getHeader() // fast
  return (
    <>
      <Header data={header} />
      <Suspense fallback={<Skeleton />}>
        <SlowSection /> {/* awaits inside, streams later */}
      </Suspense>
    </>
  )
}
```

**1.5 — Pass promises down, await in the leaf.** Start fetches high in the tree, pass the promise as prop, resolve with `use()` or `await` inside the Suspense boundary.

## 2. Bundle Size (CRITICAL)

**2.1 — Import directly, never through barrel files.**

```ts
// ❌ pulls the whole library through the barrel
import { Button } from '@/components'
// ✅ pulls one module
import { Button } from '@/components/button'
```

**2.2 — `next/dynamic` for heavy, conditionally-shown components** (charts, editors, modals, maps): `const Chart = dynamic(() => import('./chart'), { ssr: false })`.

**2.3 — Load third-party scripts after hydration** with `next/script` (`strategy="lazyOnload"` or `afterInteractive`). Never a raw `<script>` blocking render.

**2.4 — Defer modules until the feature activates** — dynamic `import()` inside the event handler that needs it (e.g., load the export-to-PDF lib on click).

**2.5 — Keep client boundaries small.** `"use client"` marks the top of a client subtree — everything it imports ships to the browser. Push `"use client"` down to the leaf interactive components; keep pages and layouts as Server Components.

## 3. Server-Side Performance (HIGH)

**3.1 — Authenticate Server Actions like API routes.** Every `"use server"` function is a public endpoint. Validate session + input inside the action, never only in the calling UI.

**3.2 — `React.cache()` for per-request deduplication** of repeated reads (e.g., `getCurrentUser()` called by layout + page + components).

```ts
export const getCurrentUser = cache(async () => {
  const session = await auth()
  return session ? db.user.findUnique({ where: { id: session.userId } }) : null
})
```

**3.3 — Cross-request caching:** `unstable_cache`/`"use cache"` or an LRU for data shared between users; always define revalidation (`revalidateTag`/`revalidatePath`) at write time.

**3.4 — `after()` for non-blocking work** — logging, analytics, notifications run after the response is sent.

**3.5 — Never fetch your own API routes from Server Components.** Call the data layer (DB/service) directly; the HTTP hop to yourself is pure overhead.

## 4. Client-Side Data Fetching (MEDIUM-HIGH)

**4.1 — Use SWR (or React Query) instead of `useEffect` + `fetch`.** Automatic dedupe, cache, revalidation, race-condition safety.

```tsx
// ❌ manual effect fetch: no dedupe, races, no cache
useEffect(() => { fetch('/api/user').then(...) }, [])
// ✅
const { data, error, isLoading } = useSWR('/api/user', fetcher)
```

**4.2 — Deduplicate global listeners** — one `resize`/`scroll` listener shared via a small store or context, not one per component instance.

**4.3 — Passive listeners for scroll/touch:** `addEventListener('scroll', fn, { passive: true })`.

**4.4 — Version localStorage payloads** (`{ v: 2, data }`) and handle both parse failure and stale versions on read.

## 5. Re-render Optimization (MEDIUM)

**5.1 — Never define components inside components.** The inner component remounts on every render, losing state and DOM.

**5.2 — Hoist non-primitive default props** (`const EMPTY: Item[] = []`) outside the component — inline `[]`/`{}`/`() => {}` defeats memoization.

**5.3 — Extract expensive subtrees into `memo()` components** and pass primitive props; prefer restructuring (move state down, pass children) over sprinkling `useMemo` everywhere.

**5.4 — Effects should depend on primitives:** `useEffect(fn, [user.id])`, not `[user]`.

**5.5 — `startTransition` for non-urgent updates** (filtering large lists, tab switches) so typing stays responsive.

## 6. Rendering Performance (MEDIUM)

**6.1 — `content-visibility: auto` for long lists**, or virtualize (`react-window`/`virtua`) above ~200 rows.

**6.2 — Prefer ternaries over `&&`** for conditional JSX — `{count && <X/>}` renders a literal `0`.

**6.3 — Extract static JSX** outside the component so it's created once.

**6.4 — Animate a wrapper `<div>` with CSS transforms, not SVG internals**; keep animations on `transform`/`opacity` (compositor-only).

**6.5 — Expected hydration mismatches** (timestamps, locale) → `suppressHydrationWarning` on that node, or render client-only via `useEffect`-gated state.

## 7. JavaScript Micro-Performance (LOW-MEDIUM)

- Use `Map`/`Set` for repeated lookups instead of `array.find`/`includes` in loops (O(1) vs O(n)).
- Combine chained `filter().map()` into one pass when the list is large and hot.
- Batch DOM writes; toggle classes instead of many inline style mutations.
- `requestIdleCallback` for non-critical deferred work.

## 8. Next.js App Router Essentials

- **`generateMetadata`** for SEO; **`next/image`** always (never raw `<img>` for content images); **`next/font`** for zero-layout-shift fonts.
- **Route handlers e páginas dinâmicas:** declare `export const dynamic`/`revalidate` explicitly quando o default implícito não for óbvio.
- **`loading.tsx` + `error.tsx`** em toda rota com fetch — streaming UX e error boundary por segmento.
- **Server Components por padrão**; client components apenas onde há interatividade real.
- **Mutations via Server Actions** com `revalidatePath`/`revalidateTag` — não faça mutate + `router.refresh()` manual quando a action resolve.

## Checklist de review (QA)

- [ ] Nenhum `await` sequencial de operações independentes
- [ ] Nenhum barrel import de libs de UI/ícones
- [ ] `"use client"` apenas em folhas interativas
- [ ] Server Actions autenticam e validam input
- [ ] Fetch client-side via SWR/React Query, não `useEffect` cru
- [ ] Nenhum componente definido dentro de componente
- [ ] Imagens via `next/image`, fontes via `next/font`
- [ ] Listas longas virtualizadas ou com `content-visibility`

---

Adaptado de vercel-labs/agent-skills → react-best-practices (skills.sh) — 2026-08-26. Seção 8 (Next.js) baseada em conhecimento próprio: a skill next-best-practices foi descontinuada (vercel-labs/next-skills arquivado; docs agora embutidas no framework).

Attribution

joaoguirunasjoaoguirunas
View sourceMore from joaoguirunas →
SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

281612 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2132 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

9881 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →