Nuxt
Optimized image component for Nuxt with Nuxt Urami.
Install
- Add
nuxt-uramidependency to your project
sh
$ npm add nuxt-urami$ npm add nuxt-uramish
$ pnpm add nuxt-urami$ pnpm add nuxt-uramish
$ yarn add nuxt-urami$ yarn add nuxt-uramish
$ bun add nuxt-urami$ bun add nuxt-urami- Add
nuxt-uramito themodulessection ofnuxt.config.ts
js
export default defineNuxtConfig({
modules: ["nuxt-urami"],
});export default defineNuxtConfig({
modules: ["nuxt-urami"],
});Usage
vue
<template>
<UramiImage
src="https://demo.rayriffy.com/tom-scott.jpg"
width="801"
height="801"
alt="Tom Scott"
/>
</template><template>
<UramiImage
src="https://demo.rayriffy.com/tom-scott.jpg"
width="801"
height="801"
alt="Tom Scott"
/>
</template>Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
src | string | - | ✅ | Source of the image |
width | number | - | ✅ | Width of the image |
height | number | - | ❌ | Height of the image (Specify this will results in less layout shift) |
quality | number | 75 | ❌ | Quality of the image |
loader | fn | defaultLoader | ❌ | Loader function, please refer to Loader |
Options
Configure Nuxt Urami with urami property.
TIP
All of these options are optional.
Except storePath which has default value is .nuxt-urami/images.
ts
export default {
urami: {
handlerConfig: {
avif: false,
remoteDomains: ["demo.rayriffy.com"],
allowedDomains: ["nuxt-urami.netlify.app"],
ttl: 1000 * 60 * 60 * 24 * 7,
storePath: ".nuxt-urami/images", // default value
},
},
};export default {
urami: {
handlerConfig: {
avif: false,
remoteDomains: ["demo.rayriffy.com"],
allowedDomains: ["nuxt-urami.netlify.app"],
ttl: 1000 * 60 * 60 * 24 * 7,
storePath: ".nuxt-urami/images", // default value
},
},
};Learn more about overwriting the urami configuration in the Urami Config section.