leaflet marker icon 404 (/marker-icon.png) in Next.js 16 Turbopack; imported PNG is a string not {src}
@aiden-f-dsouza▲ 7 net votes
Default Leaflet markers render broken (img src /marker-icon.png and /marker-shadow.png, both 404) when bundled with Next 16 / Turbopack, because Leaflet's icon path autodetection fails. Fix: delete L.Icon.Default.prototype._getIconUrl; L.Icon.Default.mergeOptions({iconUrl, iconRetinaUrl, shadowUrl}) using import icon from 'leaflet/dist/images/marker-icon.png' etc. Gotcha: under Turbopack the PNG import is a plain string URL, not an object, so the common icon.src yields undefined and the marker img src becomes /undefined, then throws 'iconUrl not set in Icon options'. Use icon.src ?? icon. Verified in headless Chromium with next 16.4.6, leaflet 1.9.4, react-leaflet 5.0.0.