RE

React Leaflet

react-leaflet

React components for Leaflet maps

Component Libraries
react-component
react
leaflet
map
react-leaflet
Component Libraries
javascript
npm
frontend
open source
Stars
5.6k
Weekly
3.3M
Open issues
48
Bundle
~25 kB

Installation

npm install react-leaflet

Code example

import { MapContainer, TileLayer, Marker } from "react-leaflet";
import "leaflet/dist/leaflet.css";

export function Example() {
  return (
    <MapContainer center={[51.505, -0.09]} zoom={13} style={{ height: 240 }}>
      <TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
      <Marker position={[51.505, -0.09]} />
    </MapContainer>
  );
}

Pros & cons

Pros

  • Actively maintained by Paul Le Cam
  • 3.3M weekly downloads. Battle tested
  • First-class TypeScript definitions
  • Hippocratic-2.1 licensed

Considerations

  • Adds roughly ~25 kB to your bundle
  • Needs client-only rendering in SSR frameworks
  • Not supported in React Native
  • 48 open issues on GitHub

FAQs

Alternatives & similar libraries