Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

React Leaflet

React components for Leaflet maps enabling interactive mapping in React applications.

3D and graphicsNPM

GitHubWebsite

1. License

License from npm.

github.com/PaulLeCam/react-leaflet

From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error

What React Leaflet does

React Leaflet wraps Leaflet layers as React components without replacing Leaflet: Leaflet does the DOM rendering, and props are used to create Leaflet instances and are immutable by default.

React Leaflet popularity

69 / 100
Gid Score, #418 overall
7.7M
downloads a week, npm
5,608
GitHub stars
61
agent projects use it
React Leaflet: downloads per weeknpm, react-leaflet 7,747,130
React Leaflet: GitHub starsPaulLeCam/react-leaflet 5,608

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How React Leaflet is used

  • React Leaflet is a dependency in 61 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (1.3% of the 4,867 JavaScript/TypeScript ones), #4 of 63 in 3d and graphics.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 388; those are left out of every share on this page.
  • The most used alternative in our scan is Mapbox GL (24 projects).
  • Projects that use it most often also use Leaflet (95.1%), Lucide React (88.5%), clsx (80.3%).

By coding agent

30 projects, 0.9%
29 projects, 1.2%
25 projects, 0.8%
6 projects, 2.2%
5 projects, 1.1%

Often used with

In 95.1% of its projects
In 88.5% of its projects
In 80.3% of its projects
In 80.3% of its projects
In 77.0% of its projects
In 96.7% of its projects
In 93.4% of its projects
In 65.6% of its projects

React Leaflet in practice

Strengths

Leaflet does the layer rendering

React only renders the <code>&lt;div&gt;</code> for <code>MapContainer</code> and the contents of UI layer components. The docs say rendering the layers to the DOM "is done by Leaflet itself".

Refs expose the Leaflet instance

Unless stated otherwise, every exported component supports a ref that exposes the created Leaflet element instance. For panes, the ref exposes the DOM element. The docs say this gives access to Leaflet's imperative APIs when required.

Layers follow the render tree

When a child component renders again, the docs say changes to its supported mutable props are applied to the map. When it is removed from the render tree, it removes its layer from the map as needed.

A key resets the map

The docs say a unique <code>key</code> on a <code>MapContainer</code> element can be set to reset it.

Watch out for

Not compatible with server-side rendering

The docs say Leaflet makes direct calls to the DOM when it is loaded, and that React Leaflet is therefore not compatible with server-side rendering.

Props are immutable by default

Props are used to create the Leaflet instance on the first render. The docs say they will not be updated in the UI when they change unless they are explicitly documented as mutable.

Some components must be replaced via key

The docs say some properties can be updated through Leaflet's setters. Other components should be completely replaced by setting a unique value on their <code>key</code> property.

More about React Leaflet

Packages around it
  • leaflet: Underlying map library
  • lucide-react: Icon components
  • clsx: className builder
  • tailwind-merge: Tailwind class merging
  • class-variance-authority: Component style variants
  • @radix-ui: Headless UI primitives
More in 3D and graphics

Alternatives

React Leaflet This page

Hippocratic-2.1Gid 697.7M/wk

Mapbox GL

WebGL-based interactive maps library for rendering vector tiles and geospatial data.

SEE LICENSE IN LICENSE.txtGid 646.4M/wk

react-map-gl

React components for MapLibre GL and Mapbox GL for interactive maps.

MITGid 583.7M/wk

Compare React Leaflet with another tool

Get started

Install it.

npm install react-leaflet

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## React Leaflet
- The docs say React Leaflet "is not compatible with server-side rendering" because Leaflet makes direct calls to the DOM when it is loaded. Account for this in SSR frameworks.
- Use other React Leaflet components and hooks only as descendants of a `MapContainer`.
- Treat component props as immutable by default. Only props explicitly documented as mutable are updated in the UI when they change.
- Mutable prop changes are compared by reference unless the docs state otherwise. They are applied by calling the relevant method on the Leaflet instance.
- For components that should be completely replaced, set a unique value on their `key` prop. To reset a whole map, set a unique `key` on `MapContainer`.
- Do not use React's `Activity` component with the map. The docs call it incompatible with how React Leaflet works.
- Use refs to Leaflet instances carefully, since imperative calls may create inconsistencies with props. For v5, React v19 is a required peer dependency and `LeafletProvider` is no longer in the core package.