Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

319
Vistas
How to export static images on Nextjs?

when I want to export my nextjs app, it says that I cannot export my images on static websites.

Error: Image Optimization using Next.js' default loader is not compatible with next export. Possible solutions: - Use next start to run a server, which includes the Image Optimization API. - Use any provider which supports Image Optimization (like Vercel). - Configure a third-party loader in next.config.js. - Use the loader prop for next/image.

How can I make it so that it does ?

Is there a way for me to simply tell it to render images statically ? I dont want to go throught other onlines images loaders..

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You need to set up a custom image loader in Next.js

In your next.config.js file, add this property to the export:

images: {
  loader: "custom"
}

And make a script called loader.js that exports this:

function imageLoader({ src }) {
  return `/images/${src}`; // REPLACE WITH YOUR IMAGE DIRECTORY
}

module.exports = imageLoader;

For each Image component, set the loader prop manually:

const imageLoader = require("PATH TO loader.js");

<Image loader={imageLoader} />
about 4 years ago · Juan Pablo Isaza Denunciar

0

I created a npm module so that we can use the Next.js <Image/> component with optimized images while using the static export functionality.

https://www.npmjs.com/package/next-image-export-optimizer

The library wraps the <Image /> component of Next.js and automatically creates optimized images using sharp.js at export time.

It uses a custom loader to create a srcset for the <img /> that the <Image /> component of Next.js creates. Then at build/export time, the images inside the public/images folder (as an example) are optimized with sharp.js and copied into the build folder.

about 4 years ago · Juan Pablo Isaza Denunciar

0

I'm going to add onto skara9's answer because it didn't quite work for me. I found a thread on github discussing it and the answer there worked for me. It just wraps around the NextJS image component and works pretty flawlessly for me.

// components/Image.js
import NextImage from "next/image";

// opt-out of image optimization, no-op
const customLoader = ({ src }) => {
  return src
}

export default function Image(props) {
  return (
    <NextImage
      {...props}
      loader={customLoader}
    />
  );
}

Make sure you change your imports and update your next.config.js

import Image from '../components/Image.js'
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda