Serve responsive images with next/image

next/image emits responsive srcset values, picks modern formats and prevents layout shift when width and height are known. Replace raw img tags on content pages, pass sizes for each layout width, mark the LCP image priority, and keep alt text meaningful. Check the rendered HTML for srcset and intrinsic dimensions rather than trusting the component defaults.

highIn codeimpact effort

Why this matters

One component handles sizing, formats and lazy loading.

Get the full breakdown

The extended brief explains when this works, when it does not, and the trade-offs. Join the waitlist and it unlocks for every tip when sign-in opens; MCP access is the paid part.

Join the waitlist

Before you start

  • Next.js project and access to the image templates
  • Known layout widths for the content column and cards

How to apply it

  1. Inventory the raw images

    Find every img tag in pages and components and note the rendered slot width. Start with the hero image and any image above the fold.

    Check: grep -rn '<img' app/ components/ lists the tags with their file paths before any change.

  2. Replace tags with next/image

    Import Image from next/image, pass width and height or fill with a positioned parent, and move alt text unchanged. Add sizes that match the CSS breakpoints.

    Check: The page renders an img with a srcset attribute containing at least two candidate widths.

  3. Prioritise the LCP image

    Add priority to the single largest above-the-fold image and remove it from every other image so the preload does not compete with critical CSS.

    Check: The rendered HTML contains one image preload link and the hero image tag carries fetchpriority=high.

  4. Confirm dimensions and formats

    Check that intrinsic width and height attributes are present and that the optimizer serves WebP or AVIF to a supporting browser, then measure LCP again.

    Check: PageSpeed Insights shows the hero image served in a modern format with no layout shift.

Get the prompt for your agent

A ready-to-paste prompt for your agent that implements this tip and verifies the result in your repo.

Join the waitlist

Source: seo-mcp playbook · curated entry · report an error

Official references

Framework notes

nextjs-app

Use `next/image` with explicit `width`/`height` or `fill` plus `sizes`; add `priority` to the LCP image and `remotePatterns` in `next.config` for remote hosts.

nextjs-pages

`next/image` works in the Pages Router; import it per component, pass `sizes` for responsive `srcset`, and keep `priority` on the hero only.

Let your agent apply this + 161 more tips.

Pre-order — $19