GitHubLinkedInWhatsAppFacebook
Rana Ahmed
HomeProjectsBlogContact
Let's talk
Rana Ahmed
HomeProjectsBlogContact

© 2026 Rana Ahmed - All Rights Reserved

Tutorial
Jul 05, 202312 min read

Optimizing Next.js Core Web Vitals

Rana Ahmed

Rana Ahmed

Full-Stack Developer

Optimizing Next.js Core Web Vitals

In the eyes of Google, performance is UX. Core Web Vitals are the standardized metrics used to measure the health of your site's user experience. In this guide, we'll look at how to master these metrics using Next.js.

Largest Contentful Paint (LCP)

LCP measures loading performance. To provide a good user experience, LCP should occur within 2.5 seconds of when the page first starts loading. In Next.js, the biggest win for LCP is using the `priority` prop on your hero image.

Cumulative Layout Shift (CLS)

CLS measures visual stability. We've all experienced pages where text jumps as an image loads—that's poor CLS. Next.js enforces best practices by requiring dimensions for images, effectively 'reserving' the space before the image even loads.

Vitals Checklist

  • Use next/image for automatic sizing and optimization.
  • Leverage next/font to prevent layout shifts during font loading.
  • Use the 'priority' prop for critical above-the-fold content.
  • Minimize main-thread work by offloading heavy tasks to Web Workers or the server.
  • Monitor real-world performance using the 'next/vitals' hook.

Interaction to Next Paint (INP)

INP is the newest metric, replacing FID. It measures overall responsiveness. A healthy INP score (under 200ms) ensures that your site feels snappy and reactive to user input, even while other things are happening in the background.

app/layout.tsx
import { useReportWebVitals } from 'next/web-vitals'

export function WebVitals() {
  useReportWebVitals((metric) => {
    console.log(metric)
    // Send to your analytics provider
  })
}

Conclusion

Optimizing for Core Web Vitals is not a one-time task—it's an ongoing commitment to your users. By leveraging the built-in tools in Next.js, you can ensure your site remains fast, stable, and responsive as it grows.

Rana Ahmed

Rana Ahmed

Full-Stack Developer

Share
Latest Articles

Related Articles

Article Image
Reasons Why You Should Switch to Tailwind CSS v4
Opinion
Sep 28, 202310 min read

Reasons Why You Should Switch to Tailwind CSS v4

Article Image
Building Accessible UI Components
Design
Sep 15, 202315 min read

Building Accessible UI Components

Article Image
10 Benefits of Using Next.js for Modern Web Apps
Development
Jul 21, 202312 min read

10 Benefits of Using Next.js for Modern Web Apps