Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NextJs export folder "out" doesn't have index.html

I’ve built a Next.js app, and I wanted to use static exporting to host the project on my hosting. The app is simple, so I didn’t use most of the features that Next.js offers. When I run: npm run build (next build && next export) i get .next folder and out folder which has the following folders: /static /chunks /css /media

I have all the needed settings (ie: output: "export", in next.config.js..)

I'm supposed to get all the static HTML files..but i haven’t get those, any solutions please?


Update:

This happened because image optimization is active and works under the hood,for that the app has to run on a server but i'm trying to generate a static website, i disabled it by adding the following to next.config.js:

module.exports = {
  images: {
    unoptimized: true,
  },
}

And it worked as expected.

like image 786
khaled sakhai Avatar asked Dec 06 '25 03:12

khaled sakhai


1 Answers

I know its late replay but this may help someone else.

I can see the HTML files in out folder when I disable the image optimization in next.config.js.

const nextConfig = {
  output: 'export',
  reactStrictMode: true,
  swcMinify: true,
  images: {
    unoptimized: true,
  },
}

Somehow the image optimization was causing issues with HTML generation.

The successful build should show generated files like the once below. Console output of next build with successful HTML generation

Refer to this issue: https://github.com/vercel/next.js/issues/40240#issuecomment-1237549085

like image 63
SaifEliyas Avatar answered Dec 07 '25 17:12

SaifEliyas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!