{"id":28084,"date":"2023-05-19T07:00:00","date_gmt":"2023-05-19T14:00:00","guid":{"rendered":"http:\/\/Optimize-Images-in-a-Next.js-App-Using-NextImage-and-Custom-Loaders"},"modified":"2026-03-15T12:22:29","modified_gmt":"2026-03-15T19:22:29","slug":"optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders","status":"publish","type":"post","link":"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders","title":{"rendered":"Optimize Images in Next.js Using Custom Loaders"},"content":{"rendered":"<div class=\"wp-block-cloudinary-markdown \"><p><a href=\"https:\/\/next.js\">Next.js<\/a> has a built-in Image Component that automatically optimizes images for your website or application. The default loader for Next.js applications uses the built-in Image Optimization API. This API optimizes images from anywhere on the web and serves them directly from the Next.js web server.<\/p>\n<p>\nNext.js provides a built-in <code>next\/image<\/code> component that simplifies the process of optimizing and serving images in your applications. With <code>next\/image<\/code>, you can automatically resize, optimize, and serve images in modern formats like WebP , based on the user&#8217;s requirements and device capabilities. This component replaces the traditional <code>&lt;img><\/code> tag, resulting in better performance and improved user experience.\n<\/p>\n<p>The Image Component provides <code>Next\/image<\/code>,  an extension of the HTML img element. It can automatically resize, optimize, and serve images in modern formats like WebP. You can specify a loader for Next\/image: this is a function that returns a URL string for the image. The parameters for the loader are: <code>src<\/code>, <code>width<\/code>, <code>quality<\/code>.<\/p>\n<p>It\u2019s important to note that the term \u201cNextimage\u201d has multiple meanings. Beyond its use in Next.js, Nextimage is also known as a large format scanning software from Contex. This software, distinct from web development, offers capabilities like scanning to multipage PDF or TIF, batch mode for higher volume jobs, and real-time image adjustments.<\/p>\n<p>\nUnder the hood, the Next.js [Image Optimizer](https:\/\/cloudinary.com\/tools\/image-optimizer) provides on-demand image processing without the need for additional build steps, including support for both local and remote image sources, ensuring a seamless and efficient usage in Next.js applications.\n<\/p>\n<p>You can also use a loader to append a domain URL to a local image. This makes it possible to serve the image from a content delivery network (CDN). For example, you can configure next.config.js with the following to serve images via Cloudinary, an image management service with a built-in fast CDN:<\/p>\n<pre class=\"js-syntax-highlighted\"><code>   module.exports = {\n      images: {\n        loader: 'cloudinary',\n        path: 'https:\/\/res.cloudinary.com\/ugwutotheeshoes\/image\/upload\/',\n      },\n    }\n<\/code><\/pre>\n<h2>NextJS Image Loader Example: Adding the Power of Cloudinary<\/h2>\n<p>Cloudinary offers a media management solution to manage, optimize, transform, and deliver visual media. <a href=\"https:\/\/cloudinary.com\/users\/register_free\">You can get Cloudinary for free for life<\/a>. You can sign up today and get started with using Cloudinary with the Next JS image loader.<\/p>\n<p>Cloudinary goes way beyond CDN: it can be used as a custom loader in Next.js to optimize rendered images (and lots more, of course). In the rest of this article, we\u2019ll show how to use Cloudinary to automatically optimize your image in Next.js.<\/p>\n<\/div>\n\n<div class=\"wp-block-cloudinary-markdown \"><h3>Sandbox<\/h3>\n<p>This project is completed on <a href=\"https:\/\/codesandbox.io\/s\/upbeat-driscoll-i1mhw?file=\/pages\/components\/NextImage.js\">CodeSandbox<\/a>, and you can fork it to get started quickly.<\/p>\n<\/div>\n\n\n  <div class=\"wp-block-cloudinary-code-sandbox \">\n    <iframe\n      src=\"https:\/\/codesandbox.io\/embed\/upbeat-driscoll-i1mhw?theme=dark&amp;codemirror=1&amp;highlights=&amp;editorsize=50&amp;fontsize=14&amp;expanddevtools=0&amp;hidedevtools=0&amp;eslint=0&amp;forcerefresh=0&amp;hidenavigation=0&amp;initialpath=%2F&amp;module=&amp;moduleview=0&amp;previewwindow=&amp;view=&amp;runonclick=1\"\n      height=\"500\"\n      style=\"width: 100%;\"\n      title=\"Optimize images with Next\/Image\"\n      loading=\"lazy\"\n      allow=\"accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking\"\n      sandbox=\"allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts\"\n    ><\/iframe>\n  <\/div>\n\n\n<div class=\"wp-block-cloudinary-markdown \"><p>You can also find the source code on <a href=\"https:\/\/github.com\/ugwutotheeshoes\/custom-loader-app\">GitHub<\/a>.<\/p>\n<h3>Prerequisites<\/h3>\n<p>To follow the steps in this article, you should have:<\/p>\n<ul>\n<li>Adequate knowledge of <a href=\"https:\/\/en.wikipedia.org\/wiki\/JavaScript\">JavaScript<\/a> and <a href=\"https:\/\/reactjs.org\/\">React.js<\/a>.<\/li>\n<li>The latest version of <a href=\"https:\/\/nodejs.org\/\">Node.js<\/a> installed.<\/li>\n<li>A terminal such as ITerm2(MacOS) or Git bash (Windows).<\/li>\n<li>A Cloudinary account. If you don\u2019t have one now, <a href=\"https:\/\/cloudinary.com\/users\/register_free\">create a free Cloudinary account now<\/a>. It only takes a second, and you can use it for free for life!<\/li>\n<\/ul>\n<h3>Setting Up a Cloudinary Account<\/h3>\n<p>After successfully creating an account, Cloudinary will redirect us to our account\u2019s dashboard, where we\u2019ll see account details that will be useful later, including:<\/p>\n<ul>\n<li>Cloud name<\/li>\n<li>API Key<\/li>\n<li>API Secret<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams_sanity\/9254501f4075f326d7a252e3e365cbb29150a344-1366x700.png\" alt=\"Image showing screenshot of Cloudinary account set up in preparation for working with Next image loader.\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1366\" height=\"700\"\/><\/p>\n<p><strong>NOTE:<\/strong> Don\u2019t share your Cloudindary credentials with anyone.<\/p>\n<h3>Installing the NextJS Image Loader Project Dependencies<\/h3>\n<p>We\u2019ll create a Next.js app in a new folder called <code>custom-loader-app<\/code> by running the following command in our terminal:<\/p>\n<pre class=\"js-syntax-highlighted\"><code>    npx create-next-app custom-loader-app\n<\/code><\/pre>\n<p>Next, we\u2019ll navigate to the project directory.<\/p>\n<pre class=\"js-syntax-highlighted\"><code>    cd custom-loader-app\n<\/code><\/pre>\n<p>Then, we\u2019ll install the <a href=\"https:\/\/cloudinary.com\/documentation\/react_integration\">Cloudinary React SDK<\/a> and <a href=\"https:\/\/lodash.com\/\">Lodash<\/a>.<\/p>\n<pre class=\"js-syntax-highlighted\"><code>    npm install cloudinary-react\n    npm install lodash\n<\/code><\/pre>\n<p>Running <code>npm run dev<\/code> starts a local development environment.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams_sanity\/00b7cf199d4bcc3a28bc4ed78c6df819e81cd340-1802x1260.png\" alt=\"Image showing screenshot of Next.JS welcome screen in preparation for working with Next image loader in Cloudinary\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1802\" height=\"1260\"\/><\/p>\n<h2>Adding a New Local Image With Next.js Image<\/h2>\n<p>Next.js provides the <a href=\"https:\/\/nextjs.org\/docs\/basic-features\/image-optimization\">next\/image<\/a> module, a wrapper of the HTML Img element. Next\/image bakes in various <a href=\"https:\/\/nextjs.org\/docs\/api-reference\/next\/image\">performance optimizations<\/a>, improving the core web vitals of pages using it. Next\/image supports both local and hosted images.<\/p>\n<p>In our project\u2019s pages\/components directory, we\u2019ll create a file called NextImage.js with the following content:<\/p>\n<pre class=\"js-syntax-highlighted\"><code>    import React from &quot;react&quot;;\n    import Image from &quot;next\/image&quot;;\n    import styles from &quot;\/styles\/Home.module.css&quot;;\n    const NextImage = () =&gt; {\n      return (\n        &lt;div className={styles.imagecontainer}&gt;\n          &lt;Image\n            className={styles.image}\n            src=&quot;\/small-dog.jpg&quot;\n            alt=&quot;Food&quot;\n            width={450}\n            height={280}\n          \/&gt;\n          &lt;h1 className={styles.nextcard}&gt;Next Image&lt;\/h1&gt;\n        &lt;\/div&gt;\n      );\n    };\n    export default NextImage;\n<\/code><\/pre>\n<p>Here, we\u2019ve imported the next\/image and rendered a local image. This image file with the title small-dog.jpg is in the project\u2019s public directory.<\/p>\n<p>Next, we\u2019ll import and render the <code>NextImage<\/code> component into the home page on pages\/index.js by replacing the existing content with:<\/p>\n<pre class=\"js-syntax-highlighted\"><code>    import Nextimage from &quot;.\/components\/NextImage&quot;;\n    import styles from &quot;..\/styles\/Home.module.css&quot;;\n    export default function Home() {\n      return (\n        &lt;div className={styles.container}&gt;\n          &lt;h1&gt;Image Optimization&lt;\/h1&gt;\n          &lt;main className={styles.main}&gt;\n          &lt;Nextimage \/&gt;\n          &lt;\/main&gt;\n        &lt;\/div&gt;\n      );\n    }\n<\/code><\/pre>\n<h2>Adding an Image Using Cloudinary as a Custom Loader<\/h2>\n<p>Next\/image allows the specification of a <a href=\"https:\/\/nextjs.org\/docs\/basic-features\/image-optimization#loaders\">loader<\/a>, which appends a domain URL to a local image, thereby serving the image from a content delivery network (CDN) and providing other optimization capabilities.<\/p>\n<p>We\u2019ll require an Image component utilizing a loader. To do this, we\u2019ll create a file in <code>pages\/components\/<\/code> titled <code>CloudinaryImage<\/code> with the following content:<\/p>\n<pre class=\"js-syntax-highlighted\"><code>    import React from &quot;react&quot;;\n    import styles from &quot;\/styles\/Home.module.css&quot;;\n    import Image from &quot;next\/image&quot;;\n    const CloudinaryImage = () =&gt; {\n      const cloudinaryImageLoader = ({ src }) =&gt; {\n        return `https:\/\/res.cloudinary.com\/ugwutotheeshoes\/image\/upload\/bo_10px_solid_rgb:f78585,e_blur:290,b_rgb:e1e6e9,c_scale,r_10,h_280,w_450\/v1632752254\/${src}`;\n      };\n      return (\n        &lt;div className={styles.nextcard}&gt;\n          &lt;Image\n            loader={cloudinaryImageLoader}\n            src=&quot;eatery\/item-8.jpg&quot;\n            alt=&quot;Food&quot;\n            width={450}\n            height={280}\n          \/&gt;\n          &lt;h1&gt;Cloudinary Image&lt;\/h1&gt;\n        &lt;\/div&gt;\n      );\n    };\n    export default CloudinaryImage;\n<\/code><\/pre>\n<p>We\u2019ve specified a custom loader in the next\/image Image component using Cloudinary. The loader defines a border, blur, crop, height, width, and radius applied as transformations.<\/p>\n<p>Alternatively, we could specify the Cloudinary as a loader in <code>next.config.js<\/code> by updating the file to:<\/p>\n<pre class=\"js-syntax-highlighted\"><code>    module.exports = {\n      images: {\n        loader: 'cloudinary',\n        path: 'https:\/\/res.cloudinary.com\/ugwutotheeshoes\/image\/upload\/',\n      },\n    }\n<\/code><\/pre>\n<p>Lastly, we\u2019ll add the created <code>CloudinaryImage<\/code> component to our home page, updating the <code>pages\/index.js<\/code> file to:<\/p>\n<pre class=\"js-syntax-highlighted\"><code>import Nextimage from &quot;.\/components\/NextImage&quot;;\nimport Cloudinary from &quot;.\/components\/CloudinaryImage&quot;;\nimport styles from &quot;..\/styles\/Home.module.css&quot;;\nexport default function Home() {\n  return (\n    &lt;div className={styles.container}&gt;\n      &lt;h1&gt;Image Optimization&lt;\/h1&gt;\n      &lt;main className={styles.main}&gt;\n        &lt;Nextimage \/&gt;\n        &lt;Cloudinary \/&gt;\n      &lt;\/main&gt;\n    &lt;\/div&gt;\n  );\n}\n<\/code><\/pre>\n<p>The resulting image URL with a loader is: <a href=\"https:\/\/res.cloudinary.com\/ugwutotheeshoes\/image\/upload\/bo_10px_solid_rgb:f78585,e_blur:290,b_rgb:e1e6e9,c_scale,r_10,h_280,w_450\/v1632752254\/eatery\/item-8.jpg\">https:\/\/res.cloudinary.com\/ugwutotheeshoes\/image\/upload\/bo_10px_solid_rgb:f78585,e_blur:290,b_rgb:e1e6e9,c_scale,r_10,h_280,w_450\/v1632752254\/eatery\/item-8.jpg<\/a><\/p>\n<p>Here\u2019s what the home page should look like now serving two images: one without a loader and the other with a loader.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams_sanity\/66378697bc078a524afbd923e0f4916c7827de85-1298x1606.png\" alt=\"Image showing NextJS image loader example with Cloudinary versus using Next image loader without Cloudinary\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1298\" height=\"1606\"\/><\/p>\n<h2>Conclusion<\/h2>\n<p>In this post we discussed how to optimize images in Next.js apps using next\/image. We also saw how to utilize custom loaders like Cloudinary to further enhance the delivery image.<\/p>\n<p>You may be interested in reading the following documentation:<\/p>\n<ul>\n<li>\n<a href=\"https:\/\/cloudinary.com\/documentation\/image_transformations\">Cloudinary transformations<\/a>\n<\/li>\n<li>\n<a href=\"https:\/\/nextjs.org\/docs\/api-reference\/next\/image\">Next\/image reference<\/a>\n<\/li>\n<\/ul>\n<\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":87,"featured_media":29092,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_cloudinary_featured_overwrite":false,"footnotes":""},"categories":[1],"tags":[134,370,212,246],"class_list":["post-28084","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-guest-post","tag-image","tag-next-js","tag-react"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.6 (Yoast SEO v26.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>NextJS Image Loader | Optimize Images in Next.js Using Custom Loaders<\/title>\n<meta name=\"description\" content=\"Learn about how to use the custom NextJS image loader to automatically optimize images on your pages.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Optimize Images in Next.js Using Custom Loaders\" \/>\n<meta property=\"og:description\" content=\"Learn about how to use the custom NextJS image loader to automatically optimize images on your pages.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders\" \/>\n<meta property=\"og:site_name\" content=\"Cloudinary Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-19T14:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-15T19:22:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1684271202\/Blog-Optimize-Nextjs-images\/Blog-Optimize-Nextjs-images.jpg?_i=AA\" \/>\n\t<meta property=\"og:image:width\" content=\"2000\" \/>\n\t<meta property=\"og:image:height\" content=\"1100\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"melindapham\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"NewsArticle\",\"@id\":\"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders#article\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders\"},\"author\":{\"name\":\"melindapham\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/0d5ad601e4c3b5be89245dfb14be42d9\"},\"headline\":\"Optimize Images in Next.js Using Custom Loaders\",\"datePublished\":\"2023-05-19T14:00:00+00:00\",\"dateModified\":\"2026-03-15T19:22:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders\"},\"wordCount\":8,\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1684271202\/Blog-Optimize-Nextjs-images\/Blog-Optimize-Nextjs-images.jpg?_i=AA\",\"keywords\":[\"Guest Post\",\"Image\",\"Next.js\",\"React\"],\"inLanguage\":\"en-US\",\"copyrightYear\":\"2023\",\"copyrightHolder\":{\"@id\":\"https:\/\/cloudinary.com\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders\",\"url\":\"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders\",\"name\":\"NextJS Image Loader | Optimize Images in Next.js Using Custom Loaders\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1684271202\/Blog-Optimize-Nextjs-images\/Blog-Optimize-Nextjs-images.jpg?_i=AA\",\"datePublished\":\"2023-05-19T14:00:00+00:00\",\"dateModified\":\"2026-03-15T19:22:29+00:00\",\"description\":\"Learn about how to use the custom NextJS image loader to automatically optimize images on your pages.\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders#primaryimage\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1684271202\/Blog-Optimize-Nextjs-images\/Blog-Optimize-Nextjs-images.jpg?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1684271202\/Blog-Optimize-Nextjs-images\/Blog-Optimize-Nextjs-images.jpg?_i=AA\",\"width\":2000,\"height\":1100,\"caption\":\"Image showing NextJS image loader example graphic of overhead view of a beach with Next image loader code sample.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudinary.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Optimize Images in Next.js Using Custom Loaders\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"name\":\"Cloudinary Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudinary.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\",\"name\":\"Cloudinary Blog\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"width\":312,\"height\":60,\"caption\":\"Cloudinary Blog\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/0d5ad601e4c3b5be89245dfb14be42d9\",\"name\":\"melindapham\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e6f989fa97fe94be61596259d8629c3df65aec4c7da5c0000f90d810f313d4f4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e6f989fa97fe94be61596259d8629c3df65aec4c7da5c0000f90d810f313d4f4?s=96&d=mm&r=g\",\"caption\":\"melindapham\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"NextJS Image Loader | Optimize Images in Next.js Using Custom Loaders","description":"Learn about how to use the custom NextJS image loader to automatically optimize images on your pages.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders","og_locale":"en_US","og_type":"article","og_title":"Optimize Images in Next.js Using Custom Loaders","og_description":"Learn about how to use the custom NextJS image loader to automatically optimize images on your pages.","og_url":"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders","og_site_name":"Cloudinary Blog","article_published_time":"2023-05-19T14:00:00+00:00","article_modified_time":"2026-03-15T19:22:29+00:00","og_image":[{"width":2000,"height":1100,"url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1684271202\/Blog-Optimize-Nextjs-images\/Blog-Optimize-Nextjs-images.jpg?_i=AA","type":"image\/jpeg"}],"author":"melindapham","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders#article","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders"},"author":{"name":"melindapham","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/0d5ad601e4c3b5be89245dfb14be42d9"},"headline":"Optimize Images in Next.js Using Custom Loaders","datePublished":"2023-05-19T14:00:00+00:00","dateModified":"2026-03-15T19:22:29+00:00","mainEntityOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders"},"wordCount":8,"publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1684271202\/Blog-Optimize-Nextjs-images\/Blog-Optimize-Nextjs-images.jpg?_i=AA","keywords":["Guest Post","Image","Next.js","React"],"inLanguage":"en-US","copyrightYear":"2023","copyrightHolder":{"@id":"https:\/\/cloudinary.com\/#organization"}},{"@type":"WebPage","@id":"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders","url":"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders","name":"NextJS Image Loader | Optimize Images in Next.js Using Custom Loaders","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders#primaryimage"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1684271202\/Blog-Optimize-Nextjs-images\/Blog-Optimize-Nextjs-images.jpg?_i=AA","datePublished":"2023-05-19T14:00:00+00:00","dateModified":"2026-03-15T19:22:29+00:00","description":"Learn about how to use the custom NextJS image loader to automatically optimize images on your pages.","breadcrumb":{"@id":"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders#primaryimage","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1684271202\/Blog-Optimize-Nextjs-images\/Blog-Optimize-Nextjs-images.jpg?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1684271202\/Blog-Optimize-Nextjs-images\/Blog-Optimize-Nextjs-images.jpg?_i=AA","width":2000,"height":1100,"caption":"Image showing NextJS image loader example graphic of overhead view of a beach with Next image loader code sample."},{"@type":"BreadcrumbList","@id":"https:\/\/cloudinary.com\/blog\/optimize-images-in-a-next-js-app-using-nextimage-and-custom-loaders#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudinary.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Optimize Images in Next.js Using Custom Loaders"}]},{"@type":"WebSite","@id":"https:\/\/cloudinary.com\/blog\/#website","url":"https:\/\/cloudinary.com\/blog\/","name":"Cloudinary Blog","description":"","publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudinary.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cloudinary.com\/blog\/#organization","name":"Cloudinary Blog","url":"https:\/\/cloudinary.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","width":312,"height":60,"caption":"Cloudinary Blog"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/0d5ad601e4c3b5be89245dfb14be42d9","name":"melindapham","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e6f989fa97fe94be61596259d8629c3df65aec4c7da5c0000f90d810f313d4f4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e6f989fa97fe94be61596259d8629c3df65aec4c7da5c0000f90d810f313d4f4?s=96&d=mm&r=g","caption":"melindapham"}}]}},"jetpack_featured_media_url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1684271202\/Blog-Optimize-Nextjs-images\/Blog-Optimize-Nextjs-images.jpg?_i=AA","_links":{"self":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/28084","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/comments?post=28084"}],"version-history":[{"count":18,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/28084\/revisions"}],"predecessor-version":[{"id":39873,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/28084\/revisions\/39873"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media\/29092"}],"wp:attachment":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media?parent=28084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/categories?post=28084"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/tags?post=28084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}