Next.js Performance: From Good to Great
Performance Matters
Every 100ms of load time costs conversions. For blogs, slow pages mean higher bounce rates and lower search rankings. For SaaS products, they mean lost revenue.
Here's how to make your Next.js app fast.
1. Choose the Right Rendering Strategy
Not every page needs the same rendering approach:
- Static Generation (SSG) — best for blog posts, marketing pages, docs
- Server-Side Rendering (SSR) — best for personalized dashboards, real-time data
- Client-Side — best for highly interactive widgets
Default to static generation. It's the fastest option and works for most content.
2. Analyze Your Bundle
Use @next/bundle-analyzer to find what's bloating your JavaScript:
ANALYZE=true npm run buildCommon culprits: date libraries (use date-fns over moment), icon libraries (import individually), and unused dependencies.
3. Optimize Images
The Next.js Image component handles responsive sizing, lazy loading, and format conversion. Always specify width and height to prevent layout shift.
For hero images, use priority to preload them:
<Image src="/hero.jpg" width={1200} height={600} priority alt="Hero" />4. Minimize Client-Side JavaScript
React Server Components are your friend. Keep components on the server unless they need interactivity. A blog post body has no reason to be a client component.
Only add "use client" when you actually need:
- Event handlers (onClick, onChange)
- State (useState, useReducer)
- Browser APIs (localStorage, IntersectionObserver)
5. Font Optimization
Use next/font to self-host fonts with zero layout shift:
import { Inter } from "next/font/google";
const inter = Inter({ subsets: ["latin"] });This eliminates the external request to Google Fonts and prevents FOIT/FOUT.
6. Caching Headers
For static assets, set aggressive cache headers. For API routes, use stale-while-revalidate patterns.
Measuring Results
Use Lighthouse, Web Vitals, and real user monitoring. Aim for:
- LCP under 2.5 seconds
- FID under 100ms
- CLS under 0.1
Conclusion
Performance optimization is iterative. Measure first, fix the biggest bottleneck, then measure again. Don't optimize prematurely — but don't ignore performance until it's a crisis either.
Jordan Lee
Building for the web since 2018. I write about React, Next.js, TypeScript, and the tools that make developers productive.