agentleFS
LeonxLJXLeonxLJX/web-engineer-skills/skills/nextjs-performance/SKILL.md

nextjs-performance

Skill0 starsChanged 2 months agoMITView on GitHub

Make Next.js App Router apps fast by default — RSC/client boundary decisions, caching layers, streaming, image and font strategy, and the bundle-diet checklist. Use when building or optimizing Next.js applications.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Default every component to a Server Component.

    line 10
  2. Very specific:

    Every route needs generateMetadata (title, description, OG) — it's also your search/snackable surface.

    line 72

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Next.js (App Router) performance

Put the boundary in the right place

Default every component to a Server Component; add 'use client' only where interactivity demands it.

  • A 'use client' marker turns the whole subtree client-side — push it to the leaves:
// ❌ the entire page ships JS
'use client'
export default function Page() { return <Chart filters={<Filters/>} /> }

// ✅ page stays server; only the leaf is interactive
// page.tsx (server)
export default function Page() {
  return <div><Filters /><Chart /></div>   // Chart.tsx has 'use client'
}
  • Server Components can pass serializable props down; never pass functions/classes across the boundary.

Data fetching: know your cache layer

LayerMechanismUse for
Request memoizationsame URL in one render passdedupe within a request
Data Cachefetch next: { revalidate }cross-request persistence
Full Route Cachestatic routespages that rarely change
Router Cacheclient-side navinstant back/forward
  • Static by default; add dynamism explicitly (cookies(), headers(), searchParams make a route dynamic — know which ones you're touching).
  • revalidateTag/revalidatePath on writes — invalidation is part of the feature, ship it with the mutation code.

Streaming: suspend below the fold

Wrap slow sections in <Suspense> so the shell ships immediately; the slow data streams in:

export default function Page() {
  return (
    <>
      <Header />                      {/* instant */}
      <Suspense fallback={<Skeleton />}>
        <SlowDashboard />             {/* streams when ready */}
      </Suspense>
    </>
  )
}

Assets

  • next/image with correct sizes; LCP image gets priority.
  • next/font (self-hosted, no layout shift, no extra request).
  • Route-level dynamic = 'force-static' where content is truly static.

Bundle diet (per PR)

  1. ANALYZE=1 next build — inspect the client graph.
  2. Replace moment/lodash full imports with date-fns/named imports.
  3. Icons: import from the icon package's ESM entry or inline SVG — no barrel of 1MB.
  4. Heavy editors/charts: next/dynamic with ssr: false and a skeleton.

Meta

  • Every route needs generateMetadata (title, description, OG) — it's also your search/snackable surface.
  • Parallel data: Promise.all in server components; sequential awaits are the #1 self-inflicted TTFB kill.

Definition of done (agent checklist)

  • 'use client' count per route is minimal and leaf-placed
  • No fetch waterfalls in server components
  • Mutations call the matching revalidate*
  • LCP element uses priority image or server-rendered text
  • Client bundle diff per PR within budget (see performance-budget skill)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.