Next.js의 <Image> 컴포넌트는 기본 HTML <img> 요소를 확장하여 다음과 같은 기능을 제공한다.
<Image> 사용을 시작하려면, next/image 에서 이를 import하고 컴포너늩 내에 렌더링하자.
app/page.tsx
import Image from 'next/image'
export default function Page() {
return <Image src="" alt="" />
}
src 속성에는 로컬 또는 원격 이미지를 사용할 수 있다.
시청각 자료:
next/image사용 방법에 대해 더 알아보자 → YouTube (9 minutes)
정적인 파일(static files)들, 예를 들어 이미지나 폰트 같은 파일들은 프로젝트의 루트 디렉터리에 있는 public 이라는 이름의 폴더 아래에 저장할 수 있다.
public 폴더 내의 파일들은 기본 URL(/)부터 시작하여 코드에서 참조될 수 있다.

app/page.tsx
import Image from 'next/image'
export default function Page() {
return (
<Image
src="/profile.png"
alt="Picture of the author"
width={500}
height={500}
/>
)
}
이미지를 정적으로 import하는 경우, Next.js는 이미지의 고유한 width 와 height 를 자동으로 결정한다.
이 값들은 이미지 비율을 결정하고, 이미지가 로딩되는 동안 누적 레이아웃 이동(Cumuldative Layout Shift)이 발생하는 것을 방지하기 위해 사용된다.
app/page.tsx
import Image from 'next/image'
import ProfileImage from './profile.png'
export default function Page() {
return (
<Image
src={ProfileImage}
alt="Picture of the author"
// width={500} automatically provided
// height={500} automatically provided
// blurDataURL="data:..." automatically provided
// placeholder="blur" // Optional blur-up while loading
/>
)
}