Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
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
  • Authors
  • 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
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Nextjs Performance

ASecurity

Next.js performance optimization for Core Web Vitals, image/font optimization, caching, streaming, bundle size, and Server Components. Use when fixing LCP/INP/CLS, implementing next/image or next/font, configuring unstable_cache, converting Client to Server Components, streaming with Suspense, or reducing bundle size. Covers Next.js 16 + React 19 patterns.

4 stars
0 votes
0 copies
0 views
Added 9/19/2026
developmentgoreactnextjsnodeapiperformance

Works with

cliapi

Security Analysis

A100/100

Pro scans all 11 files and shows the line behind each finding

Scanned 9/19/2026

$npx -y skills add jgamaraalv/delivery-loop --skill nextjs-performance --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Nextjs Performance?

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

Security grade badge for Nextjs Performance
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jgamaraalv-nextjs-performance/badge)](https://www.skillsdirectory.com/skills/jgamaraalv-nextjs-performance)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: nextjs-performance
description: Next.js performance optimization for Core Web Vitals, image/font optimization, caching, streaming, bundle size, and Server Components. Use when fixing LCP/INP/CLS, implementing next/image or next/font, configuring unstable_cache, converting Client to Server Components, streaming with Suspense, or reducing bundle size. Covers Next.js 16 + React 19 patterns.
---

# Next.js Performance Optimization

## Before Starting

1. **Analyze current performance** with Lighthouse
2. **Identify bottlenecks** - check Core Web Vitals in Chrome DevTools or PageSpeed Insights
3. **Determine optimization priority**:
   - LCP issues → Focus on images, fonts
   - INP issues → Reduce JS, use Server Components
   - CLS issues → Add dimensions, use next/font

## Core Principles

1. **Prefer Server Components** - Only use 'use client' when necessary (browser APIs, interactivity)
2. **Load components as low as possible** - Keep Client Components at leaf nodes
3. **Use Suspense boundaries** - Enable streaming and progressive loading
4. **Cache appropriately** - Use tags for granular revalidation
5. **Measure before/after** - Always verify improvements with real metrics

## References

Each file is loaded on demand — read one only when the task needs that depth (progressive disclosure).

- `references/core-web-vitals.md` — LCP/INP/CLS targets, diagnostics, and per-metric optimizations · read when measuring or fixing Core Web Vitals.
- `references/image-optimization.md` — next/image sizing, priority, blur placeholder, remotePatterns config · read when fixing LCP or image-related CLS.
- `references/font-optimization.md` — next/font setup, subsets, display swap, CSS variable integration · read when eliminating font-related CLS or FOUT.
- `references/caching-strategies.md` — unstable_cache, revalidateTag/Path, ISR, cache tags, TTL guidance · read when configuring data or route caching.
- `references/server-components.md` — Client-to-Server conversion patterns, RSC constraints, Suspense boundaries · read when moving components server-side or wiring streaming.
- `references/streaming-suspense.md` — Suspense boundaries, progressive loading, fallback skeletons · read when implementing streaming or reducing TTFB.
- `references/bundle-optimization.md` — dynamic(), code splitting, tree shaking, modularizeImports, bundle-analyzer · read when reducing initial JS bundle size.
- `references/metadata-seo.md` — static/generateMetadata, Open Graph, canonical, sitemap · read when configuring metadata or SEO.
- `references/api-routes.md` — Route Handler patterns, Edge runtime, input validation, error handling · read when optimizing API routes.
- `references/nextjs-16-patterns.md` — async params Promise, use() hook, useOptimistic, React 19 patterns · read when adopting Next.js 15+/React 19 APIs.

## Common Conversions

| From | To | Benefit |
|------|-----|---------|
| `useEffect` + fetch | Direct async in Server Component | -70% JS, faster TTFB |
| `useState` for data | Server Component with direct DB access | Simpler code, no hydration |
| Client-side fetch | `unstable_cache` or ISR | Faster repeated loads |
| `img` tag | `next/image` | Optimized formats, lazy loading |
| CSS font import | `next/font` | Zero CLS, automatic optimization |
| Static import of heavy component | `dynamic()` | Reduced initial bundle |

## Constraints and Warnings

### Server Components Limitations
- Cannot use browser APIs (window, localStorage, document)
- Cannot use React hooks (useState, useEffect, useContext)
- Cannot use event handlers (onClick, onSubmit)
- Cannot use dynamic imports with ssr: false

### Image Optimization Constraints
- `priority` should only be used for above-the-fold images
- External images require configuration in next.config.js
- `width` and `height` are required unless using `fill`
- Animated GIFs are not optimized by default

### Caching Considerations
- Cache tags must be manually invalidated
- Data cache is per-request in development
- Edge runtime has different caching behavior
- Be careful caching user-specific data

### Bundle Size Warnings
- Dynamic imports can impact SEO if critical content
- Tree shaking requires proper ES module usage
- Some libraries cannot be tree shaken (avoid barrel exports)
- Client Components increase bundle size - use sparingly

## Performance Checklist

- [ ] All images use `next/image` with proper dimensions
- [ ] LCP images have `priority` attribute
- [ ] Fonts use `next/font` with subsets
- [ ] Server Components used where possible
- [ ] Client Components at leaf level only
- [ ] Suspense boundaries for data fetching
- [ ] Caching configured for expensive operations
- [ ] Bundle analyzed for duplicates
- [ ] Heavy components lazy loaded
- [ ] Lighthouse score verified before/after

## Common Mistakes

```tsx
// ❌ DON'T: Fetch in useEffect
'use client'
useEffect(() => { fetch('/api/data').then(...) }, [])

// ✅ DO: Fetch directly in Server Component
const data = await fetch('/api/data')

// ❌ DON'T: Forget dimensions on images
<Image src="/photo.jpg" />

// ✅ DO: Always provide dimensions
<Image src="/photo.jpg" width={800} height={600} />

// ❌ DON'T: Use priority on all images
<Image src="/photo1.jpg" priority />
<Image src="/photo2.jpg" priority />

// ✅ DO: Priority only for LCP
<Image src="/hero.jpg" priority />
<Image src="/photo.jpg" loading="lazy" />

// ❌ DON'T: Cache everything with same TTL
{ revalidate: 3600 }

// ✅ DO: Match TTL to data change frequency
{ revalidate: 86400 } // Categories rarely change
{ revalidate: 60 }     // Comments change often
```

Attribution

jgamaraalvjgamaraalv
View sourceSee grades on GitHubMore from jgamaraalv →
SSkills Directory ProSkills Directory

Get any skill into Claude in one click.

Download any skill as a ZIP for Claude.ai, Claude Desktop, or .claude/skills. $9/mo.

See Pro

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 Directory ProSkills Directory

Get any skill into Claude in one click.

Download any skill as a ZIP for Claude.ai, Claude Desktop, or .claude/skills. $9/mo.

See Pro

Related Skills

Clean Code

Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments

304955 votes

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.

285172 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.

2222 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 ...

10341 votes
View all in development →