Niels-IO / next-image-export-optimizer

Use Next.js advanced <Image/> component with the static export functionality. Optimizes all static images in an additional step after the Next.js static export.
MIT License
439 stars 52 forks source link

Error 'NextRouter was not mounted' occurs when building with SSG after updating from v1.7.0 to v1.8.0 #157

Closed NPJigaK closed 1 year ago

NPJigaK commented 1 year ago

After updating from v1.7.0 to v1.8.0, I encountered an error 'NextRouter was not mounted' when building with Static Site Generation (SSG). I believe this issue stems from changes made to use useRouter. Was this an intentional change? Does this mean SSG is no longer supported?

I've been a fan of this module for its ability to optimize images even with SSG. I would like to continue using it beyond v1.8.0. I understand that resolving this issue might take some time and effort, but I would greatly appreciate your assistance. Thank you.

zifeo commented 1 year ago

Also facing this issue (diff).

Niels-IO commented 1 year ago

Hi @NPJigaK Thanks for reporting this issue. I fixed it now and got rid of the useRouter. To use the basePath, you now have to pass it as a prop to the ExportedImage.

NPJigaK commented 1 year ago

@Niels-IO I greatly appreciate your swift and efficient response. I am sincerely looking forward to seeing this library evolve and improve. Thank you once again.

Niels-IO commented 1 year ago

Is now fixed in v1.8.1 🙂