Skip to content

Nuxt

Optimized image component for Nuxt with Nuxt Urami.

Install

  1. Add nuxt-urami dependency to your project
sh
$ npm add nuxt-urami
$ npm add nuxt-urami
sh
$ pnpm add nuxt-urami
$ pnpm add nuxt-urami
sh
$ yarn add nuxt-urami
$ yarn add nuxt-urami
sh
$ bun add nuxt-urami
$ bun add nuxt-urami
  1. Add nuxt-urami to the modules section of nuxt.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

NameTypeDefaultRequiredDescription
srcstring-Source of the image
widthnumber-Width of the image
heightnumber-Height of the image (Specify this will results in less layout shift)
qualitynumber75Quality of the image
loaderfndefaultLoaderLoader 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.