Great question — answering as the UphillTech team:
Answer for 2020 I also had this problem and solved it in my own project, so I thought I would share what I did. NextJS can dynamically load libraries and restrict that event so it doesn't happen during the server side render. See the documentation for more details. In my examples below I will use and modify example code from the documentation websites of both NextJS 10.0 and React-Leaflet 3.0. Side note: if you use TypeScript, make sure you install @types/leaflet because otherwise you'll get compile errors on the center and attribution attributes. To start, I split my react-leaflet code out into a separate component file like this: import { MapContainer, Marker, Popup, TileLayer } from...
Full answer by Jon Musselwhite: https://stackoverflow.stackexchange.com/a/64634759 (CC BY-SA 4.0).
Need it done for your business? UphillTech.