The way I solved my issue with window is not defined was with the dynamic import from Next and react-leaflet v5.0.0-rc.1
After a long search I found the answer here: https://github.com/PaulLeCam/react-leaflet/issues/1133#issuecomment-2429898837