Guide
Common Issues and Tips

Common Issues and Tips

How do you debug your codebase if you have some issues? Well we will clear the throat here. Here are some common issues and tips to help you debug your codebase:

  1. Error: next/image requires width and height props:
  • Solution: Make sure you're providing the width and height props to the Image component. If you're using next/image with a dynamic image, you might need to use a library like react-use-dimensions to get the dimensions of Image
  1. Error: next/image requires src prop:
  • Solution: Make sure you're providing the src prop to the Image component. If you're using a dynamic image make sure the src prop is not empty or null.
  1. Error: next/image requires alt prop:
  • Solution: Make sure you're providing the alt prop to the Image component. This is a accessibility requirement.
  1. Error: next/image is not optimized for production:
  • Solution: Make sure you're using next/image with the optimizer option enabled. You can do this by adding optimizer to your next.config.js file.
  1. Error: next/image is not working with CSS frameworks like Tailwind CSS:
  • Solution: Make sure you're using the className prop to add classes to the Image component. If you're using a CSS framework like Tailwind CSS, you might need to add the classes to the img element instead of the Image component.
  1. Error: next/image is not working with dynamic imports:
  • Solution: Make sure you're using the import dynamic from 'next/dynamic' syntax to import the Image component. This is required for dynamic imports.
  1. Error: next/image is not working with server-side rendering (SSR):
  • Solution: Make sure you're using the next/image component with the ssr option enabled. You can do this by adding ssr to your next.config.js file.
  1. Error: next/image is not working with internationalized (i18n) routes:
  • Solution: Make sure you're using the next/image component with the i18n option enabled. You can do this by adding i18n to your next.config.js file.
  1. Error: next/image is not working with lazy loading:
  • Solution: Make sure you're using the next/image component with the lazy option enabled. You can do this by adding lazy to your next.config.js file.
  1. Error: next/image is not working with responsive images:
  • Solution: Make sure you're using the next/image component with the responsive option enabled. You can do this by adding responsive to your next.config.js file.
  1. Error: next/image is not working with WebP images:
  • Solution: Make sure you're using the next/image component with the formats option enabled. You can do this by adding formats to your next.config.js file.
  1. Error: next/image is not working with SVG images:
  • Solution: Make sure you're using the next/image component with the svg option enabled. You can do this by adding svg to your next.config.js file.
  1. Error: next/image is not working with GIF images:
  • Solution: Make sure you're using the next/image component with the gif option enabled. You can do this by adding gif to your next.config.js file.
  1. Error: next/image is not working with AVIF images:
  • Solution: Make sure you're using the next/image component with the avif option enabled. You can do this by adding avif to your next.config.js file.