images
Custom configuration for the next/image loader
If you want to use a cloud provider to optimize images instead of using the Next.js built-in Image Optimization API, you can configure next.config.js
with the following:
This loaderFile
must point to a file relative to the root of your Next.js application. The file must export a default function that returns a string, for example:
Alternatively, you can use the loader
prop to pass the function to each instance of next/image
.
Good to know: Customizing the image loader file, which accepts a function, requires using Client Components to serialize the provided function.
To learn more about configuring the behavior of the built-in Image Optimization API and the Image Component, see Image Configuration Options for available options.
Example Loader Configuration
- Akamai
- AWS CloudFront
- Cloudinary
- Cloudflare
- Contentful
- Fastly
- Gumlet
- ImageEngine
- Imgix
- PixelBin
- Sanity
- Sirv
- Supabase
- Thumbor
- Imagekit
- Nitrogen AIO