How to Optimize Website Performance with Next.js

Practical ways to make a Next.js site faster with the App Router: server rendering and ISR, next/image and next/font, less client JavaScript, third-party scripts and measuring LCP, INP and CLS.

How to Optimize Website Performance with Next.js
AK
Ashish Kamat
Full-Stack Developer & Digital Marketer
November 11, 2025
5
559
#Next.js performance#Next.js optimization#Next.js best practices#website performance#website optimization#Core Web Vitals#Lighthouse#CDN caching#web performance tips#frontend developer Nepal#Ashish Kamat#SEO Nepal

TL;DR / Key Takeaway

  • Practical ways to make a Next.js site faster with the App Router: server rendering and ISR, next/image and next/font, less client JavaScript, third-party scripts and measuring LCP, INP and CLS.

A fast website ranks better, keeps more visitors and converts more of them into customers. Next.js gives you a strong starting point, but its defaults only go so far. These are the techniques I use to make Next.js sites load fast for both Google and real users, written for the App Router (Next.js 13.4 and later, including Next.js 16).


Why Website Performance Matters

Google uses Core Web Vitals as part of its ranking systems, and slow pages lose visitors before they ever see your content, especially on mobile connections. Performance work pays off twice: better rankings and more of your visitors staying long enough to act.

The three Core Web Vitals, and the thresholds Google considers "good":

MetricMeasuresGood
LCP (Largest Contentful Paint)How fast the main content appears2.5 seconds or less
INP (Interaction to Next Paint)How quickly the page responds to taps and clicks200 ms or less
CLS (Cumulative Layout Shift)How much the layout jumps while loading0.1 or less

INP replaced First Input Delay (FID) as a Core Web Vital in March 2024, so ignore older advice that still mentions FID. (web.dev: Core Web Vitals)


1. Render on the Server, Statically Where Possible

In the App Router, components are Server Components by default: they render on the server and send HTML, not JavaScript, to the browser. Pages whose data doesn't change per visitor are rendered at build time and served from a CDN.

For content that changes occasionally, add time-based revalidation (Incremental Static Regeneration) instead of rendering on every request:

tsx
// app/blog/page.tsx — a Server Component
export const revalidate = 300; // regenerate at most every 5 minutes

export default async function BlogPage() {
  const res = await fetch('https://cms.example.com/api/posts', {
    next: { revalidate: 300 },
  });
  const posts: { slug: string; title: string }[] = await res.json();

  return (
    <ul>
      {posts.map((post) => (
        <li key={post.slug}>{post.title}</li>
      ))}
    </ul>
  );
}

For dynamic routes, generateStaticParams pre-renders every known page at build time:

tsx
// app/blog/[slug]/page.tsx
export async function generateStaticParams() {
  const posts: { slug: string }[] = await fetch('https://cms.example.com/api/posts').then((r) => r.json());
  return posts.map((post) => ({ slug: post.slug }));
}

If your CMS can call a webhook when content changes, revalidateTag refreshes just the affected data immediately instead of waiting for the timer.


2. Optimize Images with next/image

Images are usually the heaviest thing on a page and the most common cause of a slow LCP. The Image component resizes images, serves modern formats such as WebP and AVIF, lazy-loads images below the fold and reserves space so the layout doesn't jump.

tsx
import Image from 'next/image';

export function Hero() {
  return (
    <Image
      src="/hero.jpg"
      alt="Modern business website for a Kathmandu company"
      width={1200}
      height={600}
      sizes="(max-width: 768px) 100vw, 1200px"
      preload // Next.js 16+. On Next.js 13–15 use `priority` instead
    />
  );
}
  • Mark only the main above-the-fold image for preloading; it's almost always your LCP element.
  • Set sizes so phones don't download desktop-sized images.
  • Write descriptive alt text for accessibility and image search.

3. Self-Host Fonts with next/font

Web fonts loaded from a third-party server add an extra connection and often cause text to jump when the font swaps in. next/font downloads fonts at build time, serves them from your own domain and sizes the fallback font to match, which removes that layout shift:

tsx
// app/layout.tsx
import { Inter } from 'next/font/google';

const inter = Inter({ subsets: ['latin'], display: 'swap' });

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en" className={inter.className}>
      <body>{children}</body>
    </html>
  );
}

4. Ship Less JavaScript

Every kilobyte of JavaScript has to be downloaded, parsed and executed before the page responds to input, which directly affects INP.

  • Keep components as Server Components and add 'use client' only to the small interactive pieces (a menu toggle, a form), not to whole pages.
  • Load heavy client-only components, such as charts, maps or rich-text editors, when they're needed:
tsx
'use client';

import dynamic from 'next/dynamic';

const Chart = dynamic(() => import('./chart'), {
  ssr: false, // allowed only inside Client Components
  loading: () => <p>Loading chart…</p>,
});
  • Check what's in your bundle. Next.js 16 includes an analyzer for Turbopack builds:
bash
npx next experimental-analyze

On older versions, use the @next/bundle-analyzer package. Large date, icon or utility libraries imported in full are the usual culprits.


5. Load Third-Party Scripts Carefully

Analytics, chat widgets and ad scripts are a frequent cause of poor INP. Use next/script to control when they load:

tsx
import Script from 'next/script';

<Script src="https://example.com/chat-widget.js" strategy="lazyOnload" />

afterInteractive loads a script once the page is interactive, which suits analytics; lazyOnload waits until the browser is idle, which suits chat widgets and other non-essential scripts. Remove any script you no longer use.


6. Prevent Layout Shifts (CLS)

  • Give every image, video and iframe explicit dimensions, or use next/image, which does this for you.
  • Reserve space for content that loads later, such as ads, embeds and cookie banners.
  • Don't insert banners or notices above content that has already rendered.
  • Use next/font so text doesn't reflow when fonts load.

7. Use Caching and a CDN

Deploy on a platform that serves static assets and pre-rendered pages from a CDN close to your visitors. Next.js already sends long-lived cache headers for its built JavaScript, CSS and optimized images, so most of the work is choosing the right rendering strategy (step 1) and not opting pages out of caching unnecessarily, for example by reading cookies or headers in a layout that doesn't need them.

Links rendered with next/link are prefetched automatically when they scroll into view in production, so navigating between pages feels instant without any extra code.


8. Measure, Then Fix

Measure before and after every change, and track real users rather than only lab scores:

  • PageSpeed Insights: lab results plus real-user data from the Chrome UX Report
  • Lighthouse in Chrome DevTools: quick checks while you develop
  • Google Search Console: the Core Web Vitals report groups your URLs by status using real visitor data
  • useReportWebVitals: send your own visitors' metrics to your analytics
tsx
'use client';

import { useReportWebVitals } from 'next/web-vitals';

export function WebVitals() {
  useReportWebVitals((metric) => {
    console.log(metric.name, metric.value); // replace with a call to your analytics
  });
  return null;
}

Quick Optimization Checklist

  • Pages are Server Components, static or revalidated wherever possible
  • The hero image uses next/image with preload (or priority) and correct sizes
  • Fonts load through next/font
  • 'use client' only on interactive components; heavy widgets load dynamically
  • Third-party scripts use next/script with a deliberate strategy
  • Images, embeds and banners have reserved space
  • LCP, INP and CLS are monitored in Search Console

Final Thoughts

Next.js gives you the tools, but performance comes from how you use them: render on the server, send less JavaScript, handle images and fonts properly and measure with real-user data. Fix the biggest problem first (usually images or third-party scripts), measure again and repeat.

For the full reference, see the Next.js optimization documentation. If your business website is slow or failing Core Web Vitals, get in touch or see my web design services.

Frequently Asked Questions

What are Core Web Vitals?

Google's page experience metrics: Largest Contentful Paint (LCP) for loading, Interaction to Next Paint (INP) for responsiveness and Cumulative Layout Shift (CLS) for visual stability. INP replaced First Input Delay (FID) in March 2024.

Does the Next.js Image component improve performance?

Yes. It serves correctly sized images in modern formats, lazy-loads images below the fold and reserves space for them, which prevents layout shifts.

How do I measure my website's performance?

Use Google PageSpeed Insights or Lighthouse to test individual pages, and the Core Web Vitals report in Google Search Console to track how real visitors experience your site over time.

Share Article
Article Info
Published November 11, 2025
Next.js
5

Tags

Next.js performanceNext.js optimizationNext.js best practiceswebsite performancewebsite optimizationCore Web VitalsLighthouseCDN cachingweb performance tipsfrontend developer NepalAshish KamatSEO Nepal
About the Author
AK
Ashish Kamat

Full-Stack Developer & Digital Marketer

View Profile
Stay Updated

Get the latest articles and tutorials delivered to your inbox.

Subscribe Now

Related Articles

Continue your learning journey with these related articles

Digital Marketing Guide for Businesses in Biratnagar
Tips & Tricks
May 12, 2026
11
Digital Marketing Guide for Businesses in Biratnagar

Discover the complete digital marketing guide for businesses in Biratnagar. Learn local SEO, social media, content marketing, and paid ads strategies tailored for the Biratnagar market.

Digital Marketing BiratnagarLocal SEO Biratnagar+4
Read Article
Next.js 16 Released: Everything You Need to Know About the Fastest Version Yet
Next.js
November 16, 2025
8
Next.js 16 Released: Everything You Need to Know About the Fastest Version Yet

Next.js 16 has arrived with groundbreaking performance improvements including Turbopack as the default bundler, delivering 5-10x faster Fast Refresh and 2-5x faster production builds. Discover the new Cache Components, React 19.2 integration, routing system overhaul, and stable React Compiler support. Learn how to upgrade seamlessly and unlock unprecedented speed for your Next.js applications in this comprehensive guide.

nextjsnextjs16+6
Read Article
Next.js vs WordPress — Which Is Better for Your Business Website?
Next.js
November 11, 2025
5
Next.js vs WordPress — Which Is Better for Your Business Website?

Compare Next.js and WordPress for your business website. Learn which platform offers better SEO, performance, and scalability for businesses in Nepal.

Next.js vs WordPresswebsite development Nepal+3
Read Article

Need Help with Your Website?

I design and build fast, SEO-ready websites and apps for businesses across Nepal. Let's discuss your project.