Back to Nuxt

9.Nuxt Img

docs/4.api/1.components/9.nuxt-img.md

4.4.4858 B
Original Source

<NuxtImg> is a drop-in replacement for the native `` tag.

  • Uses built-in provider to optimize local and remote images
  • Converts src to provider-optimized URLs
  • Automatically resizes images based on width and height
  • Generates responsive sizes when providing sizes option
  • Supports native lazy loading as well as other `` attributes

Setup

In order to use <NuxtImg> you should install and enable the Nuxt Image module:

bash
npx nuxt module add image

Usage

<NuxtImg> outputs a native img tag directly (without any wrapper around it). Use it like you would use the `` tag:

html
<NuxtImg src="/nuxt-icon.png" />

Will result in:

html

::read-more{to="https://image.nuxt.com/usage/nuxt-img" target="_blank"} Read more about the <NuxtImg> component. ::