<Image> component extends the HTML <img> element with automatic image optimization, including resizing, format conversion (WebP/AVIF), and lazy loading.
app/page.js
Props
The source of the image. Accepts:
- An internal path string:
"/profile.png" - An absolute external URL (must be configured with
remotePatterns):"https://example.com/image.png" - A static import:
import profile from './profile.png'
The default loader does not forward request headers when fetching
src. If your image requires authentication, use unoptimized to bypass optimization.Describes the image for screen readers and search engines. Also shown as fallback text if the image fails to load.The text should replace the image without changing the meaning of the page. It does not supplement captions. For purely decorative images, use an empty string:
alt="".The intrinsic width of the image in pixels. Used to infer the aspect ratio and prevent layout shift. Does not determine the rendered size — use CSS for that.Required unless the image is statically imported or has
fill={true}.The intrinsic height of the image in pixels. Used to infer the aspect ratio and prevent layout shift. Does not determine the rendered size — use CSS for that.Required unless the image is statically imported or has
fill={true}.Expands the image to fill its parent element. The parent must have
position: relative, fixed, or absolute. The <img> element defaults to position: absolute.Use objectFit to control how the image fills the container:"contain"— scales down to fit while preserving aspect ratio"cover"— fills and crops the container
A string that maps viewport widths to image sizes, used by the browser to select the best Use
srcset entry.sizes when:- The image uses the
fillprop - CSS makes the image responsive
sizes, the browser assumes the image is full viewport width and may download unnecessarily large images.Image quality from
1 to 100. Higher values increase file size. Must match a value in the qualities config array (required in Next.js 16+).When
true, inserts a <link rel="preload"> in the <head> to fetch the image early.Use for LCP (Largest Contentful Paint) images, such as hero images above the fold. Do not combine with loading or fetchPriority.Added in Next.js 16. Replaces the deprecated
priority prop.Controls when the image loads:
"lazy"— defers loading until near the viewport"eager"— loads immediately regardless of position
Placeholder shown while the image loads:
"empty"— no placeholder"blur"— blurred version; requiresblurDataURL"data:image/..."— a Data URL used directly as the placeholder
A Data URL used as a blur-up placeholder when
placeholder="blur". Should be a very small image (10px or less) — it is enlarged and blurred automatically.Automatically set for statically imported jpg, png, webp, and avif images (unless animated). For dynamic or remote images, provide this manually.Inline CSS styles passed to the underlying If you set a custom
<img> element.width via style, also set height: 'auto' to preserve the aspect ratio.A custom function to generate image URLs. Receives
{ src, width, quality } and returns a URL string.Props that accept functions, like
loader, require a Client Component.When
true, serves the image as-is from src without changing quality, size, or format. Useful for small images, SVGs, and animated GIFs.Overrides the
src attribute on the rendered <img> element while keeping the generated srcset. Useful when migrating from <img> to <Image> and needing to preserve the original URL for SEO.Hint to the browser for image decoding strategy:
"async"— decode asynchronously; other content renders first"sync"— decode synchronously for atomic presentation"auto"— browser chooses
Callback invoked when the image finishes loading and the placeholder is removed. Receives the native event with
event.target pointing to the <img> element.Requires a Client Component.
Callback invoked if the image fails to load.
Requires a Client Component.
Deprecated props
Configuration
You can configure image behavior globally innext.config.js under the images key.
remotePatterns
Defines allowed remote image sources. Any image from a URL not matching these patterns returns a 400 error.
next.config.js
URL object shorthand:
next.config.js
*matches a single path segment or subdomain**matches any number of path segments at the end, or subdomains at the beginning
localPatterns
Restricts which local paths can be optimized.
next.config.js
formats
Output image formats in preference order. Defaults to ['image/webp'].
next.config.js
deviceSizes
Device width breakpoints used to generate responsive srcset entries.
next.config.js
imageSizes
Additional image widths concatenated with deviceSizes for images that use the sizes prop.
next.config.js
qualities
Allowlist of permitted quality values. Required in Next.js 16+.
next.config.js
minimumCacheTTL
Time-to-live (in seconds) for cached optimized images. Defaults to 14400 (4 hours).
next.config.js
loaderFile
Path to a custom image optimization loader, relative to the project root.
next.config.js
getImageProps
Returns the props that <Image> would pass to the underlying <img> element without rendering the component. Useful for art direction, background images, and canvas.
app/page.js
Examples
Local image
Statically imported images have theirwidth and height inferred automatically.
app/page.js
Remote image
Providewidth and height explicitly since Next.js cannot inspect remote files at build time.
app/page.js
Fill layout
Usefill when the image dimensions are unknown. The parent container must be positioned.
Blur placeholder
blurDataURL is set automatically.
Background image
app/page.js
Version history
| Version | Changes |
|---|---|
v16.0.0 | preload prop added, priority deprecated, qualities default changed to [75] |
v14.0.0 | onLoadingComplete deprecated |
v13.0.0 | next/image stable, next/legacy/image renamed |
