Skip to main content

Using Sirv CDN with Nuxt

Take advantage of the simplicity of Nuxt Image and power of Sirv with the official Nuxt/Image module. Your original Nuxt Image props will automatically translate to Sirv URL parameters.

Listed below are more than 100 options to scale, crop and apply watermarks, text and other effects. Try all the options in the dynamic imaging demo.

Live Nuxt demo​

Play with the Nuxt Image live demo in your browser on StackBlitz or CodeSandbox.

Or you can check out a statically generated version here.

Getting started​

  1. Install the @nuxt/image module by following the instructions here.

  2. Sign up for a Sirv account if you haven't already, and grab your account name from the settings page.

  3. Add your base Sirv URL to your Nuxt config file:


    // nuxt.config.ts
    image: {
    sirv: {
    baseURL: 'https://youralias.sirv.com/'
    }
    }

  4. That's it! Now you can enjoy the convenience of Nuxt Image and powerful image optimization and delivery options of Sirv.

Usage​

Sirv will automatically pick up standard Nuxt Image parameters like width, format, fit, quality and so on. E.g, this code:




Will render as:

![](https://demo.sirv.com/harris-large.jpg?w=500&format=png)

To use Sirv specific parameters, you can use the modifiers prop, here's an example:




This will return this image:

Sirv watermark demo

<img class="Sirv" data-src="https://demo.sirv.com/t-shirt-man.jpg?watermark=/watermark-v1.png&watermark.position=center&watermark.scale.width=30%&h=500" alt="Sirv watermark demo" />

Full list of options​

Here's a full list of available modifiers:

[table]

ParameterTranslates toDescription
widthwWidth of image
heighthHeight of image
ssResize the image by its biggest side
qualityqJPEG image quality (percentage)
fitscale.optionImage scaling options
profileprofileApply a Sirv profile
formatformatImage format served (defaults to optimal)
webpFallbackwebp-fallbackImage format for browsers without WebP support
subsamplingsubsamplingChroma subsampling to reduce JPEG file size
gifCompressiongif.lossyApply lossy compression, to reduce GIF file size
cropcrop.typeAutomatically crop to edge of image contents; point of interest; or face
cropArcrop.aspectratioAspect ratio of the crop
cwcwCrop the image to a specific width
chchCrop the image to a specific height
cxcxPosition to start image crop (from top)
cycyPosition to start image crop (from left)
cropPaddingXcrop.pad.xAdd padding to left/right of crop area
cropPaddingYcrop.pad.yAdd padding to top/bottom of crop area
canvasHeightcanvas.heightCreate a canvas around the image (height)
canvasWidthcanvas.widthCreate a canvas around the image (width)
canvasArcanvas.aspectratioAspect ratio of the canvas from 1-99 e.g. 16:9
canvasPositioncanvas.positionPosition of the canvas behind the image
canvasBorderWidthcanvas.border.widthAdds additional width left and right of the canvas
canvasBorderHeightcanvas.border.heightAdds additional height above and below the canvas
canvasBorderColorcanvas.border.colorColor of the canvas border e.g. E0AA80 or red
canvasBorderOpacitycanvas.border.opacityOpacity of the canvas border
watermarkwatermarkFilepath of the image to be overlayed
watermarkPositionwatermark.positionPosition of the watermark on the image
watermarkPositionGravitywatermark.position.gravityStarting point for shifting the x & y values
watermarkPositionXwatermark.position.xPosition of the watermark (from left)
watermarkPositionYwatermark.position.yPosition of the watermark (from top)
watermarkWidthwatermark.scale.widthWidth of watermark
watermarkHeightwatermark.scale.heightHeight of watermark
texttextDisplay text on your image
textBase64text.text64Alternative to text parameter, with Base64 encoding
textSizetext.sizeWidth of text area in relation to image
textAligntext.alignAlign the multiline text
textPositiontext.positionLocation of the text on the image
textPositionXtext.position.xLocation of the text (from left)
textPositionYtext.position.yLocation of the text (from top)
textPositionGravitytext.position.gravityMaster location of the text on the image
textFontSizetext.font.sizeFix the size of the text in px
textFontStyletext.font.styleStyle of the text
textFontFamilytext.font.familyChoose a font e.g. "Open Sans"
textFontWeighttext.font.weightChoose font weight (light, normal, semi-bold, bold, extra-bold)
textColortext.colorText color e.g. E0AA80 or E0AA8020
textOpacitytext.opacityText opacity
textOutlineWidthtext.outline.widthAdd an outline around the text
textoutlineColortext.outline.colorColor of the text outline
textOutlineOpacitytext.outline.opacityOpacity of the text outline
textOutlineBlurtext.outline.blurBlur the edge of the text outline
textBackgroundColortext.background.colorBackground color e.g. E0AA80 or E0AA8020
textBackgroundOpacitytext.background.opacityBackground opacity
sharpensharpenSharpen the image
blurblurBlur the image
grayscalegrayscaleMake the image black & white
colorizecolorizeOverlay a color on the image
colorizeColorcolorize.colorThe color of the colorize option
colorizeOpacitycolorize.opacityOpacity of the color overlay
colortonecolortoneChange the color tone of the image
colortoneColorcolortone.colorApply a color tone to an image
colortoneLevelcolortone.levelSet the level of blending with the original image
colortoneModecolortone.modeApply the color tone to the entire image or shadows/highlights only
vignettevigette.valueAdjust the depth of the vignette
vignetteColorvigette.colorAdd a vignette (dark edges) around the image
lightnesslightnessChange the lightness of the image
colorlevelBlackcolorlevel.blackAdjust black level of image
colorlevelWhitecolorlevel.whiteAdjust white level of image
histogramhistogramDisplay a histogram of RGB levels
huehueChange the hue of the image
saturationsaturationChange the saturation of the image
highlightshighlightsChange the highlights of the image
shadowsshadowsChange the shadows of the image
brightnessbrightnessChange the brightness of the image
exposureexposureChange the exposure of the image
contrastcontrastChange the contrast of the image
rotaterotateNumber of degrees to rotate the image
flipflipFlip image vertically (mirror)
flopflopFlip image horizontally (mirror)
opacityopacityOpacity of PNG images
frameStyleframe.styleAdd a frame around the image
frameColorframe.colorFrame color e.g. E0AA80 or E0AA8020
frameWidthframe.widthFrame width
frameRimColorframe.rim.colorFrame rim color e.g. E0AA80 or E0AA8020
frameRimWidthframe.rim.widthFrame rim width
pdfPagepagePage number of PDF when converted to image

[/table]

Get expert help​

If you need help using Sirv with Nuxt Image, please contact us. We love helping users and always reply within 24 hours.