Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Import Image from next/image, provide meaningful alt text, and give remote or dynamic images intrinsic width and height unless you use fill. Then match sizes to the CSS layout, allow only required remote paths with images.remotePatterns, and choose loading behavior deliberately. The component extends the HTML <img> element with Next.js image optimization, including responsive delivery, reserved layout space and lazy loading.

This guide follows the App Router API documented on March 16, 2026, and notes differences you may encounter in older Next.js versions. Check your installed version before copying configuration or loading examples.

1. Install and import the component

In a Next.js project, import the component wherever you render an image:

import Image from 'next/image'

Use it in a server or client component just as you would use an HTML image, but pass Next.js props instead of relying only on CSS attributes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
export default function Hero() {
  return (
    <Image
      src="/images/hero.jpg"
      alt="A mountain trail at sunrise"
      width={1600}
      height={900}
    />
  )
}

The official documentation describes the component as extending HTML <img> for automatic image optimization (Next.js Image Component API).

2. Choose a local image source

Files in the public directory

Put a file such as public/images/hero.jpg in the project and reference it with a root-relative URL:

<Image src="/images/hero.jpg" alt="A mountain trail at sunrise" width={1600} height={900} />

The URL is relative to the site origin; do not write /public/images/hero.jpg. You must provide dimensions for this URL because it is a string at runtime.

Static imports

Importing an image file lets Next.js read its dimensions at build time. The imported object supplies the intrinsic metadata automatically:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import Image from 'next/image'
import portrait from '@/public/images/portrait.jpg'

export default function Profile() {
  return <Image src={portrait} alt="Portrait of the author" />
}

Static imports are useful for bundled assets because a missing or malformed file is detected during the build rather than only when a request is made.

3. Understand width, height and the rendered size

width and height communicate intrinsic dimensions. The browser uses them to infer the aspect ratio and reserve space before the file arrives, reducing layout movement. They do not force the final CSS width and height.

<Image
  src="/images/card.jpg"
  alt="A notebook on a desk"
  width={1200}
  height={800}
  className="card-image"
/>
.card-image {
  width: 100%;
  height: auto;
}

Keep the dimensions’ ratio consistent with the source. If you deliberately crop with CSS, make that choice explicit with object-fit and a constrained box.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

4. Use fill when the parent owns the image box

fill makes the image occupy its positioned parent instead of taking dimensions from width and height. The parent needs a positioning context such as relative, absolute or fixed, and it must have a usable size.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
export default function Cover() {
  return (
    <div className="cover">
      <Image
        src="/images/cover.jpg"
        alt="Snow-covered forest"
        fill
        sizes="(max-width: 768px) 100vw, 50vw"
        style={{ objectFit: 'cover' }}
      />
    </div>
  )
}
.cover {
  position: relative;
  min-height: 20rem;
}

Use object-fit: contain when the entire image must remain visible, or cover when filling the box is more important than showing every edge.

5. Match sizes to responsive CSS

sizes tells the browser how wide the image will be rendered at different viewport widths. Next.js generates a srcset; the browser uses sizes to select an appropriate candidate. For a responsive or fill image, omitting sizes can make the browser assume the image is viewport-wide and download a larger resource than necessary.

<Image
  src="/images/product.jpg"
  alt="Blue running shoes"
  width={1200}
  height={1200}
  sizes="(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 33vw"
  style={{ width: '100%', height: 'auto' }}
/>

Here the image is one column on small screens, half a container on medium screens and roughly one third on large screens. Write conditions that describe your actual layout, not a universal guessed value.

6. Configure remote images safely

Next.js cannot inspect a remote file during your build, so remote URLs need explicit dimensions (or fill). They also need an allowlist in next.config.js. Prefer remotePatterns, which can constrain protocol, hostname, port and pathname:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
/** @type {import('next').NextConfig} */
const nextConfig = {
  images: {
    remotePatterns: [
      {
        protocol: 'https',
        hostname: 'images.example.com',
        port: '',
        pathname: '/products/**',
      },
    ],
  },
}

module.exports = nextConfig

Use the narrowest path your application needs. A pattern such as /products/** does not authorize unrelated image paths. Restart the development server after changing the configuration.

export default function Product() {
  return (
    <Image
      src="https://images.example.com/products/shoe.jpg"
      alt="Blue running shoe"
      width={1200}
      height={1200}
    />
  )
}

The older images.domains setting is deprecated since Next.js 14 because it cannot restrict protocol, port or pathname as precisely. The Pages Router guidance also documents remote patterns and responsive sizing (Pages Router Image API).

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

7. Write useful alt text

  • Describe the information the image adds, such as alt="Checkout form showing a successful payment".
  • For a decorative image, use alt="" so assistive technology skips it.
  • Do not repeat a nearby caption word for word.
  • Do not omit alt; it is required for an accessible image.

8. Control loading and the LCP image

Images are lazy loaded by default. Keep that behavior for below-the-fold content. Use loading="eager" when an image must be requested immediately:

<Image
  src="/images/hero.jpg"
  alt="Product dashboard"
  width={1600}
  height={900}
  loading="eager"
/>

In Next.js 16, priority is deprecated in favor of preload. The current App Router reference cautions that preloading can be inappropriate when several images might be LCP candidates, or when loading or fetchPriority is already used. Select one justified above-the-fold image rather than marking every image as critical:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<Image
  src="/images/hero.jpg"
  alt="Product dashboard"
  width={1600}
  height={900}
  preload
/>

For projects on an older version, read that version’s API reference before replacing an existing priority prop. The migration guidance is version-specific (App Router Image API).

9. Configure quality and output formats

The reference lists a default quality setting of 75. In Next.js 16, the qualities configuration is required; declare the values your application permits:

const nextConfig = {
  images: {
    qualities: [25, 50, 75, 90],
  },
}

module.exports = nextConfig

If a requested quality is not in the configured list, the component uses the closest allowed value. Treat quality as a visual and bandwidth trade-off, not as a guaranteed performance number.

10. Useful props and advanced controls

Styling and layout

  • className and style apply presentation rules.
  • objectFit can be expressed through CSS or inline style for fill layouts.
  • unoptimized bypasses the default optimizer for a particular image; use it only when your delivery setup requires that behavior.

Custom loaders

A custom loader receives a source, width and quality and returns the URL for your image transformation service:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
function cdnLoader({ src, width, quality }) {
  return `https://cdn.example.com/${src}?w=${width}&q=${quality ?? 75}`
}

<Image
  loader={cdnLoader}
  src="photos/desk.jpg"
  alt="Desk with a laptop"
  width={1200}
  height={800}
/>

Keep the loader’s URL construction controlled; do not turn it into an unrestricted proxy.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Other image attributes

Props such as decoding, crossOrigin, referrerPolicy and fetchPriority are useful when you understand the browser behavior they change. Avoid combining competing loading signals without a specific reason.

11. A complete responsive example

import Image from 'next/image'

export default function ArticleCard() {
  return (
    <article className="article-card">
      <div className="article-card__media">
        <Image
          src="https://images.example.com/products/story.jpg"
          alt="Developer reviewing code on a laptop"
          fill
          sizes="(max-width: 700px) 100vw, 360px"
          style={{ objectFit: 'cover' }}
        />
      </div>
      <h2>Building a faster image pipeline</h2>
    </article>
  )
}
.article-card__media {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
}

The remote pattern must authorize https://images.example.com/products/**. The aspect ratio gives the parent a height, while sizes describes its one-column and fixed-card layouts.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

12. Troubleshoot common failures

“Un-configured host” or remote image errors

Cause: the URL does not match a remotePatterns entry, including protocol, port or pathname. Fix: add the exact required pattern, restart Next.js, and keep the path as narrow as practical.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

“Image with src … must use width and height”

Cause: a remote or string source has no intrinsic dimensions. Fix: add accurate width and height, or use fill inside a sized, positioned parent.

The image is stretched or cropped unexpectedly

Cause: CSS dimensions do not preserve the source ratio, or object-fit: cover is cropping the box. Fix: use height: auto for intrinsic images, or choose contain and adjust the parent aspect ratio.

A fill image has zero height

Cause: the parent has no height or positioning context. Fix: set position: relative and give the parent a height, min-height or aspect-ratio.

The browser downloads an image that is too large

Cause: missing or inaccurate sizes on a responsive image. Fix: express the actual CSS widths at each breakpoint.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

An old tutorial’s priority warning appears

Cause: Next.js 16 deprecates priority. Fix: review whether the image is genuinely critical, then use the current preload, loading or fetch-priority guidance for your installed version.

The remote file fails intermittently

Cause: the origin may require authentication, block the optimizer, return a non-image response or be unavailable. Fix: verify the URL with a direct request, check response headers and status, ensure the origin allows your server to fetch it, and provide a stable fallback or local asset.

13. Performance, reliability and cost decisions

  • Use static imports for bundled assets and remote patterns for controlled external origins.
  • Reserve layout space with intrinsic dimensions or a sized fill parent.
  • Set sizes from real CSS breakpoints so the browser can select an appropriate candidate.
  • Leave noncritical images lazy; reserve eager or preload behavior for a demonstrated above-the-fold need.
  • Keep quality values intentional and configured rather than assuming one number suits every image.
  • Remember that optimization still depends on the remote origin being reachable and returning valid image data.

The official getting-started guide describes qualitative benefits including device-appropriate sizing, visual stability, lazy loading and remote-image resizing; it does not establish a universal numerical speed or bandwidth improvement (Next.js Images guide).

Or skip the browser setup

If your task is to capture a rendered page rather than build an image pipeline, ScreenshotNeo provides a website screenshot API and MCP server. It accepts cookie and consent banners before capture, removes more than 60 known consent platforms plus newsletter popups and chat widgets, and lets you turn each cleanup step off. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits cost nothing; the response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for all options. The same endpoint supports PNG, JPEG, WebP and PDF, full-page or selector captures, dark mode, device presets, retina scale, custom CSS and JavaScript, clicks, waits, blocking rules, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage reporting and an OpenAPI specification. An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

A free plan includes 1,000 screenshots per month without a card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan. Create a free ScreenshotNeo account.

14. Quick decision checklist

  • Is the source a static import, a local public path or a remote URL?
  • If it is remote or dynamic, did you provide dimensions or deliberately choose fill?
  • Does the fill parent have position and a real height?
  • Does sizes match the rendered CSS width?
  • Does remotePatterns allow only the required protocol, host and path?
  • Is alt informative, or intentionally empty for decoration?
  • Is lazy loading appropriate, and are you following the installed version’s Next.js 16 preload guidance?
  • Are configured quality values and any custom loader aligned with your delivery service?

Frequently Asked Questions

Can I use a plain HTML img tag instead?

Yes, but you give up the Next.js Image component’s optimization and layout features. Use a plain element only when your delivery or compatibility requirements specifically call for it.

Does width=”100%” make the Next.js image responsive?

CSS can make the rendered image responsive, but you should also provide a matching sizes value so the browser chooses an appropriately sized srcset candidate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should every image use preload?

No. Reserve preload or eager loading for a justified above-the-fold image; keep ordinary content lazy.

Why does a remote image need an allowlist?

The allowlist limits which external URLs Next.js may optimize, reducing accidental or unsafe open-ended fetching.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.