Blog
Next.jsPerformance

ENGINEERING

Optimizing Next.js for Performance

Practical techniques for making your Next.js applications faster, from server components to edge functions.

MC

Michael Cummings

December 10, 2025 · 5 min read

Next.js logo on a dark background with performance metrics and lighthouse scores overlaid

Performance is a feature. Here's how I optimize Next.js applications for speed.

Server Components First

React Server Components are the biggest performance win in Next.js:

// This component runs on the server
// Zero JavaScript sent to the client
async function ProductList() {
  const products = await db.products.findMany();
  return (
    <ul>
      {products.map(p => <li key={p.id}>{p.name}</li>)}
    </ul>
  );
}

Strategic Client Components

Only use 'use client' when you need:

  • Event handlers (onClick, onChange)
  • State (useState, useReducer)
  • Browser APIs (localStorage, window)
  • Image Optimization

    Always use next/image:

    import Image from 'next/image';
    
    <Image
      src="/hero.jpg"
      alt="Hero"
      width={1200}
      height={600}
      priority // For above-the-fold images
    />

    Edge Runtime

    For global applications, edge functions reduce latency:

    export const runtime = 'edge';
    
    export async function GET(request: Request) {
      // Runs close to your users
      return Response.json({ hello: 'world' });
    }

    Caching Strategies

    Use the new caching APIs:

    // Cache for 1 hour, revalidate in background
    export const revalidate = 3600;

    Measuring Performance

    Use Next.js built-in analytics or Web Vitals:

  • LCP: < 2.5s (Largest Contentful Paint)
  • FID: < 100ms (First Input Delay)
  • CLS: < 0.1 (Cumulative Layout Shift)
  • Performance optimization is iterative. Measure, improve, repeat.


    MC

    Michael Cummings

    Full-Stack Engineer