Using image module in your Nuxt project is only one command away. ✨
v0
documentation compatible with Nuxt 2. Check out v1.image.nuxtjs.org for Nuxt 3 support. (Announcement).Add @nuxt/image
devDependency to your project:
yarn add --dev @nuxt/image@v0
Add the module to buildModules
in your nuxt.config
:
export default { target: 'static', buildModules: [ '@nuxt/image', ]}
If you use server
target (default) and are using the default provider, add @nuxt/image
to modules
section instead:
export default { modules: [ '@nuxt/image', ]}
<nuxt-img>
and <nuxt-picture>
components in your Nuxt app ✨Add an image
section in your nuxt.config.js
:
export default { image: { // Options }}
See module options for available options.
If you're using Typescript, add the types to your "types" array in tsconfig.json
after the @nuxt/types
(Nuxt 2.9.0+) or @nuxt/vue-app
entry.
{ "compilerOptions": { "types": ["@nuxt/types", "@nuxt/image"] }}
If an error occurs during installation:
12.x
, 14.x
or 16.x
(NodeJS Downloads page)yarn upgrade @nuxt/image
rm yarn.lock && yarn
sharp
and node-gyp
, it is is probably becase your OS architecture or NodeJS version is not included in pre-built binaries and needs to built from source (for example, this sometimes occurs on Apple M1). Checkout node-gyp for install requirements.