Consider this Next.js Image component usage:
import Image from 'next/image';
export default function Avatar() {
return (
<Image
src="/avatar.png"
alt="User Avatar"
width={100}
height={100}
priority
/>
);
}What does the priority prop do here?
Think about what helps important images load faster on the page.
The priority prop tells Next.js to preload the image, so it loads immediately during page load. This is useful for important images like avatars or logos.
You want to display an image from https://example.com/photo.jpg using Next.js Image component. Which code snippet is correct?
Remember the width and height props must be numbers, not strings.
Next.js Image requires numeric width and height props for layout calculations. Option C uses numbers correctly.
Look at this code snippet:
import Image from 'next/image';
export default function Logo() {
return (
<Image
src="/logo.svg"
alt="Company Logo"
width={null}
height={50}
/>
);
}What error will this cause and why?
Check the type requirements for width and height props.
The width prop must be a number. Passing null causes a TypeError because Next.js cannot calculate layout.
Consider this component:
import Image from 'next/image';
export default function Background() {
return (
<div style={{ position: 'relative', width: '400px', height: '300px' }}>
<Image
src="/background.jpg"
alt="Background"
layout="fill"
objectFit="cover"
/>
</div>
);
}What will you see on the page?
Think about how layout='fill' and objectFit='cover' work together.
With layout='fill', the image fills the parent container which must have position relative and set size. objectFit='cover' ensures the image covers the area without distortion, cropping if needed.
Choose the correct statement about how Next.js optimizes images using the Image component.
Think about what Next.js does automatically and what requires config.
Next.js Image component automatically optimizes images by resizing them to requested sizes, lazy loading by default, and serving modern formats like WebP when supported by the browser.