Components
Legacy Image migration
Legacy next/legacy/image is deprecated and retained only for migration. Replace layout=responsive with a modern Image, intrinsic dimensions, responsive CSS and a sizes hint that matches actual layout. This example shows before and after components; render them separately in a constrained parent. Verify exact installed availability. Source: https://nextjs.org/docs/pages/api-reference/components/image-legacy. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.
Formal Syntax & Structure
nextjs syntaxnextjs
import Image from 'next/legacy/image'Working Example
Example Snippetnextjs
import LegacyImage from 'next/legacy/image';import Image from 'next/image';export function OldCover(){return <LegacyImage src="/covers/moss.png" width={120} height={180} alt="Moss book cover" layout="responsive"/>;}export function Cover(){return <Image src="/covers/moss.png" width={120} height={180} alt="Moss book cover" style={{width:'100%',height:'auto'}} sizes="(max-width: 600px) 100vw, 240px"/>;}