next-export-optimize-images is a utility for Next.js applications designed to optimize images during the build process, specifically for projects utilizing `next export` to generate static sites. It brings the benefits of Next.js's built-in image optimization, typically available only in server-rendered or deployed environments, to static exports. The library, currently at v4.7.0, maintains an active release cadence with several updates per year, focusing on new features, bug fixes, and compatibility improvements, such as adding chunking for image processing and support for Node.js v22. Key differentiators include its use of `sharp` for fast image processing, the ability to convert image formats (e.g., PNG to WebP), local downloading of external images, and a robust caching mechanism to prevent redundant optimizations. It fully supports TypeScript and Next.js App Router, providing a comprehensive solution for high-performance static websites.
npm install next-export-optimize-imagesVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to configure `next-export-optimize-images` in `next.config.mjs` and use `next/image` for local assets for build-time optimization in a Next.js static export.
Ensure `output: 'export'` is present in your `next.config.mjs`.
Upgrade your Node.js environment to version 18 or later.
Add `images: { unoptimized: true }` to your `next.config.mjs`.For remote images, consider using the provided `RemoteImage` component or declare remote URLs in `remoteOptimizedImages.js` as per documentation.
Set `output: 'export'` and `images: { unoptimized: true }` in your `next.config.mjs`.Verify the image path is correct relative to your `public` directory or the location of statically imported images. Check `public` folder for images.
Update your Node.js environment to version 18 or higher.