vercel/next.js · error
Specified images should be an object received ${typeof image
Error message
Specified images should be an object received ${typeof images}.
See more info here: https://nextjs.org/docs/messages/invalid-images-config What it means
When `images` is provided in the config, it must be an object literal matching the ImageConfig shape. The guard at config.ts:647-651 runs after the config is cast to ImageConfig, so any non-object truthy value (string, number, array, boolean) is rejected before any image-optimization defaults are applied. This prevents the downstream _next/image optimizer from dereferencing undefined properties like `images.domains`.
Source
Thrown at packages/next/src/server/config.ts:648
if (result.basePath !== '/') {
if (result.basePath.endsWith('/')) {
throw new Error(
`Specified basePath should not end with /, found "${result.basePath}"`
)
}
if (result.assetPrefix === '') {
result.assetPrefix = result.basePath
}
}
}
if (result?.images) {
const images: ImageConfig = result.images
if (typeof images !== 'object') {
throw new Error(
`Specified images should be an object received ${typeof images}.\nSee more info here: https://nextjs.org/docs/messages/invalid-images-config`
)
}
if (images.localPatterns) {
if (!Array.isArray(images.localPatterns)) {
throw new Error(
`Specified images.localPatterns should be an Array received ${typeof images.localPatterns}.\nSee more info here: https://nextjs.org/docs/messages/invalid-images-config`
)
}
// avoid double-pushing the same pattern if it already exists
if (
!images.localPatterns.some(
(pattern) =>
pattern.pathname === '/_next/static/media/**' &&
pattern.search === ''
)
) {View on GitHub (pinned to 0ae8c72462)
Solutions
- Set `images` to an object, e.g. `images: { loader: 'cloudinary', path: 'https://...' }`.
- Remove the `images` key entirely if you want the defaults.
- Verify with TypeScript by typing next.config: `const nextConfig: import('next').NextConfig = { images: { ... } }`.
Example fix
// before
module.exports = { images: 'cloudinary' }
// after
module.exports = { images: { loader: 'cloudinary', path: 'https://my-account.cloudinary.com' } } Defensive patterns
Strategy: type-guard
Validate before calling
if (config.images != null && (typeof config.images !== 'object' || Array.isArray(config.images))) {
throw new Error('images must be a plain object');
} Type guard
function isImageConfig(v: unknown): v is Record<string, unknown> {
return typeof v === 'object' && v !== null && !Array.isArray(v);
} Prevention
- Type next.config as `NextConfig` so TypeScript rejects primitives for `images`.
- Review config diffs that touch the `images` key.
When it happens
Trigger: Setting `images: 'cloudinary'`, `images: ['cloudinary']`, `images: true`, or any non-object truthy value in next.config. Also happens when a typo or bad merge leaves images as a primitive.
Common situations: Confusing the loader name string (`images: 'cloudinary'`) with the proper config object. Misreading older docs that put `loader` at a different level. Accidentally assigning the result of a function call that returns a string instead of an object.
Related errors
- Specified images.localPatterns should be an Array received $
- Specified images.remotePatterns should be an Array received
- Specified images.remotePatterns must have protocol "http" or
- Invalid assetPrefix provided. Original error: ${error}
- Specified images.domains should be an Array received ${typeo
AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06).
Data as JSON: /api/errors/517412050b213574.
Report an issue: GitHub.