Skip to the solution
EasyFrontend5 min read

next/font and next/image — how do they combine for Core Web Vitals?

915 views

The problem

Question presented to candidate: "Our Lighthouse report shows a slow LCP and some layout shift on the landing page. How would next/image and next/font help, and which settings would you change?"

What a strong answer should cover:

  • LCP (Largest Contentful Paint) is usually the hero image or heading: preload the hero image and serve it at the right size and format.
  • CLS (Cumulative Layout Shift) comes from images without reserved space and fonts that swap to a different size.
  • next/image reserves space from width and height, lazy-loads below-the-fold images and serves WebP or AVIF at the right width.
  • next/font self-hosts and preloads fonts and adds a size-adjusted fallback so the swap does not shift text.
  • In Next.js 16 use preload (or fetchPriority="high") instead of the deprecated priority for the LCP image.

Clarifying questions expected:

  • "What is the LCP element on this page?" — the fix differs for an image or a text block.
  • "Where does the shift happen?" — images, fonts, or late-inserted content like banners.

Code / implementation expected: Yes — a landing page hero using both.

  • next-font
  • next-image

Try it yourself

Sketch your approach before you read the solution. That is what the interview tests.

Stuck? Get a hint.

A short nudge toward the approach. It will not give the answer away.

Solution

The solution is hidden so you can try first

5 min read · 8 sections

Read the code

A landing hero with both tools
// app/page.tsx
import Image from "next/image";
import { Inter } from "next/font/google";
import hero from "@/public/hero.jpg";

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

export default function Landing() {
  return (
    <main className={inter.className}>
      <h1>Summer collection</h1>
      <Image src={hero} alt="Models in the summer collection" preload sizes="100vw" placeholder="blur" />
      <Image src="/grid-1.jpg" alt="Shirt" width={600} height={800} sizes="(max-width: 768px) 50vw, 25vw" />
    </main>
  );
}

Discussion

Other approaches, follow-ups and how it went in real interviews.

Sign in to join the discussion.

No comments yet. Share how you would answer it.

Question 7 of 129 in Next.js

Keep your momentum going.

Mark this question solved to track your progress, then take the next one while it is fresh.

All Next.js questions
Up nextEasy

What is Next.js and what problems does it solve?

Continue