Skip to main content
The <Image> component extends the HTML <img> element with automatic image optimization, including resizing, format conversion (WebP/AVIF), and lazy loading.
app/page.js

Props

string
required
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.
string
required
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="".
number
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}.
number
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}.
boolean
default:"false"
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
string
A string that maps viewport widths to image sizes, used by the browser to select the best srcset entry.
Use sizes when:
  • The image uses the fill prop
  • CSS makes the image responsive
Without sizes, the browser assumes the image is full viewport width and may download unnecessarily large images.
number
default:"75"
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+).
boolean
default:"false"
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.
string
default:"lazy"
Controls when the image loads:
  • "lazy" — defers loading until near the viewport
  • "eager" — loads immediately regardless of position
string
default:"empty"
Placeholder shown while the image loads:
  • "empty" — no placeholder
  • "blur" — blurred version; requires blurDataURL
  • "data:image/..." — a Data URL used directly as the placeholder
string
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.
object
Inline CSS styles passed to the underlying <img> element.
If you set a custom width via style, also set height: 'auto' to preserve the aspect ratio.
function
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.
boolean
default:"false"
When true, serves the image as-is from src without changing quality, size, or format. Useful for small images, SVGs, and animated GIFs.
string
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.
string
default:"async"
Hint to the browser for image decoding strategy:
  • "async" — decode asynchronously; other content renders first
  • "sync" — decode synchronously for atomic presentation
  • "auto" — browser chooses
function
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.
function
Callback invoked if the image fails to load.
Requires a Client Component.

Deprecated props

boolean
deprecated
Deprecated in Next.js 16. Use preload instead.
function
deprecated
Deprecated in Next.js 14. Use onLoad instead.

Configuration

You can configure image behavior globally in next.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
Alternatively, use a URL object shorthand:
next.config.js
Wildcard patterns:
  • * 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 their width and height inferred automatically.
app/page.js

Remote image

Provide width and height explicitly since Next.js cannot inspect remote files at build time.
app/page.js

Fill layout

Use fill when the image dimensions are unknown. The parent container must be positioned.

Blur placeholder

For statically imported local images, blurDataURL is set automatically.

Background image

app/page.js

Version history