npm install --save-dev @next/bundle-analyzer

# next.config.js
const withBundleAnalyzer = require("@next/bundle-analyzer")({
  enabled: process.env.ANALYZE === "true",
});
module.exports = withBundleAnalyzer({ /* ...existing config */ });

# Run the analyzer:
ANALYZE=true npm run build
