Skip to content

Vercel's Image Optimization also works with images stored and sourced from a CDN, instead of your local repository. This guide shows how you can use images hosted on Cloudinary and use next/image to automatically optimize them.

  • A Cloudinary account set up and ready to use
  • next/image installed and configured to source images locally. See the Examples section for setup instructions

In order to source images remotely from Cloudinary, use the remotePatterns configuration. This will tell Next.js where to source the images from based on a domain. Open the next.config.js file in your project and add the following code:

module.exports = {
  images: {
    remotePatterns: [
        protocol: 'https',
        hostname: '',
        port: '',
        pathname: '/my-account-name/**',

Next swap the image's src attribute to point towards your Cloudinary upload folder:

  alt="Picture of a triangle"

Vercel's Image Optimization will automatically optimize this remotely sourced image.