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

  1. Set `images` to an object, e.g. `images: { loader: 'cloudinary', path: 'https://...' }`.
  2. Remove the `images` key entirely if you want the defaults.
  3. 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

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


AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06). Data as JSON: /api/errors/517412050b213574. Report an issue: GitHub.