All articles
Engineering

Next.js image optimization for car sites

The Image component, remote patterns, sizing and caching: how Next.js car sites serve vehicle imagery fast without fighting the framework.

Robin AshfordOctober 12, 20266 min read
Blog hero: nextjs-vehicle-images

Next.js ships with strong image opinions, and car sites test every one of them: hundreds of remote images per page, aspect ratios that must not shift, and a CDN already sitting in front of the assets. Used well, the framework and a vehicle image API reinforce each other; used naively, they optimise the same bytes twice and bill you for the privilege. Here is the setup that works in production.

Let one optimizer win

The Image component wants to resize and re encode everything through its own pipeline. Vehicle imagery from a parameterised API arrives already sized and already WebP, so the double optimisation adds latency and compute for nothing. The clean pattern: request exact widths from the API, and let the component handle layout, lazy loading and priority without re processing, or scope its remote patterns narrowly and pass through what is already optimal.

Blog inline: nextjs-vehicle-images
  • Request the rendered width from the API, per breakpoint
  • Configure remote patterns for the image host once, tightly
  • Use fill or explicit dimensions to lock aspect ratio boxes
  • Reserve priority for the above the fold hero, nothing else

Rendering strategy by page type

Car sites split naturally along data freshness. Detail pages of live inventory want server rendering with short revalidation, so price and availability stay honest. Category and landing pages tolerate longer static lives, and their image URLs, being stable and parameterised, cache perfectly at every layer. The image system stays identical across strategies; only the revalidation windows differ, which keeps the mental model small.

The gallery, the grid and the fold

The three car site surfaces map cleanly onto framework primitives. The search grid uses fixed ratio cells with lazy loading below the fold, exactly as the search guide prescribes. The detail gallery preloads its first image with priority and defers the angle set until interaction. The comparison view leans on identical framing from the API, so equal sized cells need no per image fiddling. None of this is clever; all of it is deciding once and encoding the decision in components.

A VehicleImage component worth having

Wrap the framework's Image once: props for the stable vehicle ID, angle, width hint and alt text, URL construction inside, sizing and loading defaults applied. Every surface then renders vehicles through one component, and the day you change a parameter convention, one file changes. Add a fixed ratio skeleton and a branded fallback for misses, and the edge cases are designed instead of discovered.

Frameworks reward teams that decide image policy once and encode it, and punish teams that decide it per page.

For the caching architecture underneath, the caching strategy pairs with this setup directly, and the React and Vue guide covers the component pattern for stacks beyond Next.

Deploys, caches and the stable URL dividend

A last production note: because the API's URLs are stable and parameterised, they survive your deploys untouched, which keeps CDN caches warm across releases and spares the framework's optimizer from reprocessing a catalogue that did not change. Teams migrating from locally stored assets notice the difference on the first deploy after: the image layer simply is not part of the release anymore, and build times and cache hit rates both say so.

Want these images for your inventory?

Tell us which vehicles you list and we will send back real examples from your own stock.

Robin Ashford
Written by
Robin Ashford
Head of Content

Robin writes about the place where cars meet software: imagery, vehicle data and the systems that sell vehicles online. A decade across marketplaces, leasing platforms and dealer tools taught her which problems are real, and the writing here sticks to those.

Found this useful?

Add as a preferred source on Google