Logo

dev-resources.site

for different kinds of informations.

The "images.domains" Configuration is Deprecated 🐞

Published at
1/9/2025
Categories
nextjs
typescript
frontend
react
Author
joodi
Categories
4 categories in total
nextjs
open
typescript
open
frontend
open
react
open
Author
5 person written this
joodi
open
The "images.domains" Configuration is Deprecated 🐞

Resolving the The "images.domains" Configuration is Deprecated Error in Next.js

Image description

Starting from Next.js version 12.3.0, the images.domains configuration has been deprecated. Instead, you should use the new images.remotePatterns configuration. This guide explains how to update your configuration to resolve this warning.


Current Configuration

If your current configuration looks like this:

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: false, // Disabling Strict Mode
  images: {
    domains: ["images.pexels.com"],
  },
};

export default nextConfig;
Enter fullscreen mode Exit fullscreen mode

This configuration is now deprecated and may stop working in future releases.


Required Changes

To fix this, update your configuration to use images.remotePatterns. This new setting provides more granular control over external image sources.

Updated Configuration:

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: false, // Disabling Strict Mode
  images: {
    remotePatterns: [
      {
        protocol: "https",
        hostname: "images.pexels.com",
        pathname: "/**",
      },
    ],
  },
};

export default nextConfig;
Enter fullscreen mode Exit fullscreen mode

Explanation of the New Configuration

  • protocol: Specifies the protocol of the image source, e.g., https or http.
  • hostname: Defines the domain from which images are allowed.
  • pathname: Specifies the image path. Use / for the root path or /images/** for all subpaths.

Why This Change?

  1. Enhanced Security: The new configuration allows you to restrict image loading to specific sources, paths, and protocols.
  2. Greater Flexibility: You can define not just domains but also paths and protocols for external images.

Note

After making these changes, restart your project to apply the updated configuration.


Final next.config.js Output

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: false, // Disabling Strict Mode
  images: {
    remotePatterns: [
      {
        protocol: "https",
        hostname: "images.pexels.com",
        pathname: "/**",
      },
    ],
  },
};

export default nextConfig;
Enter fullscreen mode Exit fullscreen mode

With these changes, the warning about images.domains will be resolved, and your project will be fully compatible with the latest versions of Next.js.

nextjs Article's
30 articles in total
Favicon
Open-Source TailwindCSS React Color Picker - Zero Dependencies! Perfect for Next.js Projects!
Favicon
Have you ever used `git submodules`?
Favicon
Open-Source React Icon Picker: Lightweight, Customizable, and Built with ShadCN, TailwindCSS. Perfect for Next.js Projects!
Favicon
Run NextJS App in shared-hosting cPanel domain!
Favicon
10 Must-Have VS Code Extensions for 2025 πŸ”₯
Favicon
has anyone find a fix for this issue on build of next and payload CMS version 2 (sharp issue) ./node_modules/sharp/build/Release/sharp-win32-x64.node Module parse failed: Unexpected character ' ' (1:2) You may need an appropriate loader to handle this
Favicon
Github Actions with Vercel in 2024
Favicon
Building Production-Grade Web Applications with Supabase – Part 1
Favicon
Simplifying API Routes in Next.js with next-api-gen
Favicon
How to Create and Consume a REST API in Next.js
Favicon
100 Days of Code
Favicon
Nextjs + Openlayers integration
Favicon
Deploying a Next.js UI App on S3 Using Jenkins🀩
Favicon
#Vinnifinni
Favicon
How to Combine English Folders with Polish Paths in Next.js (Rewrites, Redirects, and Middleware)
Favicon
Nextjs 15
Favicon
The "images.domains" Configuration is Deprecated 🐞
Favicon
Shared form with config files in NextJs
Favicon
Page can't be indexed in Google Search Console
Favicon
Why I Chose Node.js Over Next.js for My Website's Back-End
Favicon
How to add Email and Password authentication to Nextjs with Supabase Auth
Favicon
Analytics Tool For React Devs (Vercel Analytics Alternative)
Favicon
Harnessing the Power of Self-Hosted Supabase on Coolify: A Complete Guide to Server Setup and OAuth Providers Integration
Favicon
Smart and Modular Validation Toolkit
Favicon
How to customize Next.js metadata
Favicon
How to Use TensorFlow.js for Interactive Intelligent Web Experiences
Favicon
How to add Github oAuth in Nextjs with Supabase Auth | Login with Github
Favicon
NextJs: How to create a dedicated layout file for index page
Favicon
checa como se hace una conexiΓ³n entre nextjs y la autenticaciΓ³n de supabase
Favicon
πŸ“£ Calling All Programmers!

Featured ones: