What is @nuxt/image?
@nuxt/image is a Nuxt.js module that provides a powerful and flexible way to handle images in your Nuxt applications. It offers features like automatic image optimization, responsive images, and support for various image providers.
What are @nuxt/image's main functionalities?
Automatic Image Optimization
Automatically optimizes images for better performance. The `nuxt-img` component handles the optimization process, ensuring that images are served in the most efficient format and size.
<template>
<div>
<nuxt-img src="/path/to/image.jpg" width="800" height="600" />
</div>
</template>
Responsive Images
Generates responsive images that adapt to different screen sizes. The `sizes` attribute allows you to specify different widths for the image, ensuring it looks good on all devices.
<template>
<div>
<nuxt-img src="/path/to/image.jpg" :sizes="[320, 640, 1024]" />
</div>
</template>
Support for Various Image Providers
Supports multiple image providers like Cloudinary, Imgix, and more. You can specify the provider using the `provider` attribute, allowing you to leverage the features and optimizations offered by these services.
<template>
<div>
<nuxt-img provider="cloudinary" src="/path/to/image.jpg" />
</div>
</template>
Other packages similar to @nuxt/image
gatsby-image
A package for Gatsby.js that provides image optimization and responsive images. It is tailored for Gatsby applications and offers features like lazy loading and image placeholders.
react-image
A React component for handling images, offering features like lazy loading and image placeholders. While it doesn't provide as many built-in optimizations as @nuxt/image, it is a flexible solution for React applications.
Nuxt Image
Plug-and-play image optimization for Nuxt apps. Resize and transform your images using built-in optimizer or your favorite images CDN.
Features
<nuxt-img>
drop-in replacement for the native <img>
element<nuxt-picture>
drop-in replacement for the native <picture>
element.- Built-in image resizer and transformer with unjs/ipx
- Support 20+ providers
- Generate responsive sizes
- Optimize using modern formats such as webp and avif
- ... and more
Nuxt 2
Note: This branch is for Nuxt 3 compatible module. Checkout v0
branch for Nuxt 2 support. (Announcement)
Contributing
- Clone this repository
- Enable Corepack using
corepack enable
- Install dependencies using
pnpm install
- Run
pnpm dev:prepare
to generate type stubs. - Use
pnpm dev
to start playground in development mode.
📑 License
Published under the MIT License