Use Next.js’s Image component by importing it from next/image, supplying src and meaningful alt text, and providing intrinsic width and height for remote or dynamic images. Use fill when the parent defines the image box, and add a sizes value whenever the image can render at different widths. Allow remote URLs with a narrowly scoped images.remotePatterns entry. This gives you optimization, reserved layout space and responsive resource selection without manually writing an <img> srcset.
The official documentation describes it this way: “The Next.js Image component extends the HTML <img> element for automatic image optimization.” See the current App Router Image reference and the Pages Router reference; both pages were updated in 2026.
Install and import the component
Next.js includes the component; there is no separate image package to install. In a component file, import it directly:
import Image from 'next/image'
export default function Hero() {
return (
<Image
src="/hero.jpg"
alt="A mountain lake at sunrise"
width={1600}
height={900}
/>
)
}
With the App Router, this can be a Server Component by default. Add 'use client' only when the surrounding component needs client-side state or event handlers. The same import and props work in the Pages Router.
#1 Best Overall
Choose the correct sizing model
| Situation | Use | What you must provide |
|---|---|---|
| The image has a known intrinsic ratio and a normal flow position | width and height |
Both dimensions (unless a static import supplies them) |
| The parent controls the box, such as a card thumbnail or hero overlay | fill |
A positioned parent and usually sizes |
| A local file imported from the project | Static import | Next.js reads dimensions automatically |
| A URL returned by a CMS or other remote service | Remote src |
Manual dimensions or fill, plus an allowlisted remotePatterns entry |
Intrinsic dimensions
width and height describe the source image’s intrinsic dimensions. They let the browser infer the aspect ratio and reserve space before the file arrives; they do not force those exact CSS pixels on screen. CSS, a parent layout and the rendered width determine the displayed size.
<Image
src="https://images.example.com/products/camera.jpg"
alt="Black mirrorless camera with a 24–70 mm lens"
width={1200}
height={800}
className="product-image"
/>
fill and a positioned parent
Use fill when the container, rather than the image’s intrinsic dimensions, defines the box. The parent must establish positioning, commonly with position: relative. Set object-fit to control cropping.
<div className="hero-frame">
<Image
src="/hero.jpg"
alt="People hiking beside a glacier"
fill
sizes="100vw"
style={{ objectFit: 'cover' }}
/>
</div>
.hero-frame {
position: relative;
min-height: 28rem;
}
Without a positioned parent, the absolutely positioned image has no reliable containing box. Use contain instead of cover when the complete image must remain visible.
Local images: public files and static imports
Files in public
Place public/hero.jpg in the project and reference it with a root-relative path:
Recommended Free Tools
<Image
src="/hero.jpg"
alt="A city skyline at dusk"
width={1800}
height={1000}
/>
The leading slash is important: it addresses the file from the site’s public root.
Static imports
Importing a local image lets Next.js read its dimensions during the build, so you do not have to repeat them:
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
import Image from 'next/image'
import portrait from '@/public/portrait.jpg'
export default function Profile() {
return <Image src={portrait} alt="Portrait of the author" />
}
Still write useful alt text. Automatic dimensions do not make an image accessible by themselves.
Remote images and remotePatterns
Next.js cannot inspect a remote file at build time, so a remote URL needs dimensions (or fill). You must also explicitly allow the URL pattern in next.config.js. The older images.domains option has been deprecated since Next.js 14 because it cannot constrain protocol, port or pathname as precisely.
// next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'images.example.com',
port: '',
pathname: '/catalog/**',
},
],
// In Next.js 16, declare the quality values your app accepts.
qualities: [50, 75, 90],
},
}
module.exports = nextConfig
Keep the pathname as narrow as your application permits. A pattern for one host’s catalog path is safer than allowing every path on every HTTPS host. Restart the development server after changing this file.
<Image
src="https://images.example.com/catalog/camera.jpg"
alt="Mirrorless camera in black finish"
width={1200}
height={800}
/>
If a CMS can return arbitrary hosts, validate the URL on your server and map it to an approved host or path; do not turn the allowlist into a wildcard merely to silence an error.
Make responsive images download the right resource
sizes describes the image’s expected rendered width at each viewport condition. The browser uses it with the generated srcset to choose an appropriate resource. For a responsive or fill image, omitting sizes can make the browser assume the image is viewport-wide and request a larger file than the layout needs.
<Image
src="/article-cover.jpg"
alt="Laptop displaying a dashboard"
fill
sizes="(max-width: 768px) 100vw, 50vw"
style={{ objectFit: 'cover' }}
/>
This says the image is full viewport width up to 768 CSS pixels and roughly half the viewport on wider screens. Match the string to your actual CSS grid, not to the source file’s dimensions. If a fixed card is 320 pixels wide at every breakpoint, a value such as sizes="320px" is more accurate.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Rank #3
Write useful alternative text
- Describe the information a sighted user needs from the image, not every visual detail.
- For a functional image, describe the action or destination (for example, “Open account settings”).
- When a nearby caption already conveys the information, avoid repeating it in
alt. - For purely decorative artwork, use
alt=""so assistive technology can skip it.
Control loading and above-the-fold images
Images are lazy loaded by default. That is generally appropriate for content below the initial viewport. If a specific image must be requested immediately, use loading="eager" or an appropriate fetch priority after identifying the loading need.
Version matters. 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 being used. Do not copy a pre-Next-16 priority example without checking the version installed in your project. Keep below-the-fold images lazy.
<Image
src="/home-hero.jpg"
alt="The product dashboard on a laptop"
width={1600}
height={900}
loading="eager"
/>
Use this only for a genuinely above-the-fold image. Changing every image to eager loading increases competing requests rather than fixing a single loading bottleneck.
Quality, formats and custom loaders
The reference lists a default quality setting of 75. In Next.js 16, the values accepted by the quality prop are constrained by the configured images.qualities list; a requested value that is not listed is matched to the closest allowed value. Choose an allowed value for your application’s visual and bandwidth trade-off instead of treating 75 as a universal performance target.
If your images are transformed by another service, a custom loader function receives the source, requested width and quality and returns the transformation URL. Keep that function deterministic and ensure the resulting host and path are covered by your deployment’s image configuration. The official API reference documents the loader signature and current props.
A complete App Router example
This page combines a remote image, responsive sizing, a positioned frame and a local static import:
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
import Image from 'next/image'
import logo from '@/public/logo.png'
export default function ProductPage() {
return (
<main>
<Image src={logo} alt="Acme logo" />
<section className="feature">
<Image
src="https://images.example.com/catalog/camera.jpg"
alt="Mirrorless camera with a detachable lens"
fill
sizes="(max-width: 700px) 100vw, 60vw"
style={{ objectFit: 'cover' }}
/>
</section>
</main>
)
}
.feature {
position: relative;
width: 100%;
aspect-ratio: 3 / 2;
}
The remote host must match the remotePatterns entry shown earlier. The aspect ratio reserves a stable box while the remote file loads.
Pages Router usage
In pages/, the component API is the same:
import Image from 'next/image'
export default function About() {
return (
<Image
src="/team.jpg"
alt="The engineering team in the office"
width={1400}
height={933}
sizes="(max-width: 800px) 100vw, 800px"
/>
)
}
Use the Pages Router’s Image API page when your project remains on that router, and check its version notes before adopting examples from another release.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteTroubleshooting checklist
“Invalid src prop” or an unconfigured host
The URL does not match remotePatterns exactly. Check protocol, hostname, port and pathname, then restart Next.js after editing next.config.js. Do not rely on the deprecated domains setting for a new configuration.
The image is stretched, cropped or unexpectedly large
Verify the intrinsic ratio, the parent’s dimensions and the CSS object-fit. For fill, confirm the parent is positioned. For responsive layouts, make sizes describe the actual rendered width.
A large image downloads on mobile
An omitted or inaccurate sizes value can make the browser assume viewport width. Replace a guessed value with media conditions that mirror your layout.
Layout shifts while the image loads
Provide correct width/height, use a static import, or give a fill parent a stable height or aspect ratio. A zero-height parent leaves the filled image no usable box.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Best Value
The remote image returns 404 or fails optimization
Open the exact URL directly, confirm it is reachable without an expiring authorization token, and check that the configured pathname includes it. If a CDN requires headers or signed URLs, return a stable, authorized image URL from your application or use a documented custom loader.
A hero image is still late
First confirm it is the actual above-the-fold/LCP candidate. Then use an appropriate eager-loading or current-version preload strategy, not a blanket change on every image. Next.js 16 deprecates priority; follow the installed version’s reference.
Performance and reliability decisions
- Reserve layout space with intrinsic dimensions or a stable
fillcontainer. - Use
sizesthat match CSS so the browser does not fetch unnecessarily wide variants. - Keep remote allowlists narrow and predictable; a changing host or path is a configuration problem, not a reason to allow everything.
- Leave ordinary and below-the-fold images lazy. Change loading only for a measured, identifiable need.
- Pick quality values from the configured list in Next.js 16 and assess the visual result for your content; the documentation does not establish a universal speed or bandwidth number.
For the qualitative benefits and setup guidance, see the Next.js images getting-started guide.
Or skip the browser setup
If you need a screenshot of a rendered Next.js page for documentation, visual checks or an AI workflow, ScreenshotNeo returns a PNG, JPEG, WebP or PDF from one request. It is separate from next/image: your Next.js app still handles image optimization, while ScreenshotNeo captures the page a visitor sees.
Before capture, ScreenshotNeo accepts the cookie or consent banner and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be turned off. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.
Here is a one-call capture of a Next.js site (replace the URL with your deployed page):
curl -G "https://api.screenshotneo.com/v1/shot"
-d access_key=YOUR_API_KEY
--data-urlencode url=https://nextjs.org
-o shot.webp
Equivalent Python:
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://nextjs.org"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
Equivalent Node.js:
const q = new URLSearchParams({
access_key: 'YOUR_API_KEY',
url: 'https://nextjs.org',
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
See the ScreenshotNeo API documentation for options such as viewport and device presets, full-page capture, CSS selectors, waits, custom headers and cookies, PDF output, caching, signed links, asynchronous jobs and bulk capture. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account.
Quick Recap
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.
Free tools Windows power users keep installed
One-click scans. No signup required.




