Image Optimization using the default loader is not compatible with { output: 'export' }
Last verified:
The fix
Image Optimization using the default loader is not compatible with { output: 'export' }. The default loader needs the server. On a static export, set images.unoptimized. On Vercel, drop output: 'export' if you want the optimizer.
- 1
Decide whether this deploy is a static export
A host that only serves files, including a static upload, needs
output: 'export'. Vercel running Next.js does not. If the project is deployed as a Next.js app on Vercel, removeoutput: 'export'and keep the default loader. Do not set both and expect optimization. - 2
For a static export, turn optimization off
Set
images.unoptimizedtotruenext tooutput: 'export'. The<Image>component still requireswidthandheight, orfill. It will not call/_next/image. Restart the dev server after changing the config./** @type {import('next').NextConfig} */ const nextConfig = { output: "export", images: { unoptimized: true }, }; module.exports = nextConfig; - 3
Do not swap in a loader you have not written
A custom
images.loadermust be a string path to a function that returns the final URL. Leavingloader: 'default'withoutput: 'export'is this error. Do not pointloaderat an empty file to silence the build. - 4
Keep remote hosts for the optimizer you still use
After you remove
output: 'export', a remotesrcstill has to be listed underimages.remotePatterns. That failure names the hostname. It is not this export error. A local file inpublic/does not need a remote pattern.
Why it happens
The default next/image loader asks the Next.js server to resize the file when a browser requests it. output: 'export' writes HTML, JS, and CSS files and does not run that server. Next throws Image Optimization using the default loader is not compatible with { output: 'export' }. The same check lists two ways out: remove output: 'export' and run with next start, or set images.unoptimized so the browser loads the file directly.
The docs page for this error also allows a custom loader, which has to build the image URL itself, and a host that provides the optimization API. Vercel does, when the app is a Next.js server deployment rather than a folder of exported files. A hostname that is not in images.remotePatterns is a different error, and it only appears once the optimizer is actually running.
The next error you'll probably hit
Once this is fixed, the usual follow-up is Invalid src prop on `next/image`, hostname is not configured under images in your `next.config.js`. Invalid src prop (https://…) on next/image, hostname "…" is not configured under images in your next.config.js. Add that host to images.remotePatterns and restart. A file in public/ does not need a pattern.
Prompt to paste back into your AI tool
Paste this above the error.
Next.js throws: Image Optimization using the default loader is not compatible with { output: 'export' }. The config file is <path>. We deploy to <Vercel or a static host>.
Do not remove the Image component and inline a broken URL. Do not add images.remotePatterns to fix this sentence. Do not leave loader: 'default' on a static export.
1. If we deploy to Vercel as a Next.js app and we want optimization, remove output: 'export'.
2. If the host only serves files, set images.unoptimized to true and keep output: 'export'.
3. Do not add a custom loader unless I already have one. Show the config diff only.Common questions
+The site is on Vercel. Should I set unoptimized?
Only if you are actually exporting static files. A Next.js deployment on Vercel includes the optimizer. Remove output: 'export' instead of turning optimization off.
+I set unoptimized and now the hostname error is gone too. Did that fix remote images?
Unoptimized skips the optimizer, so remotePatterns is not consulted. The browser requests the src directly. That is fine for a static export. It is not the fix you want if you removed output: 'export' and still need the hostname allowlist.
Related errors
- Invalid src prop on `next/image`, hostname is not configured under images in your `next.config.js`Invalid src prop (https://…) on `next/image`, hostname "…" is not configured under images in your `next.config.js`. Add that host to images.remotePatterns and restart. A file in public/ does not need a pattern.Cursorv0BoltNext.jsReactNov 5, 2026
- No Output Directory named "dist" foundNo Output Directory named "dist" found after the Build completed. Vercel looked for a folder the build did not write. Set the framework preset to the app you actually build, or point Output Directory at the folder that exists.CursorLovableBoltVercelViteOct 27, 2026
- Dynamic server usage: Route couldn't be rendered statically because it used `cookies`Dynamic server usage: Route couldn't be rendered statically because it used `cookies`. Await cookies() on the same call stack, outside setTimeout, and do not swallow that throw. The route can then render per request.Cursorv0BoltNext.jsReactNov 6, 2026
- 404 on refresh of a client routeA 404 on refresh means the Vite app works from /, then a reload of /dashboard misses index.html. Rewrite unknown paths to index.html on the host.CursorLovableBoltReactViteOct 16, 2026