Library / SDK
visgl/react-map-gl avatar
visgl/react-map-gl

react-map-gl: two map engines behind one React import path

React friendly API wrapper around MapboxGL JS

8,513 stars1,345 forksTypeScriptNOASSERTION

At a glance

What is it?
react-map-gl is a set of React components over mapbox-gl or maplibre-gl, and the engine you install decides the import path, the stylesheet and the token. What the README itself documents is one component and two short examples, with the rest of the API living on a separate docs site.
Who is it for?
Adopt react-map-gl when you have already chosen mapbox-gl or maplibre-gl and want React props instead of engine callbacks. Skip it if you need a documented marker, popup or draw API and will not read the external docs, or if you are still shopping for a basemap.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository last received commits 29 days ago.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • visgl/react-map-gl8,513 ★ · +8
Star history
Repository2026-09-222026-11-22
visgl/react-map-gl8.5k8.5k

8 Stars in the last 61 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The import path picks your engine before any prop is read

Two subpaths ship in the same package, and they are not interchangeable. `react-map-gl/maplibre` binds the components to maplibre-gl, `react-map-gl/mapbox` binds them to mapbox-gl, and the stylesheet has to come from whichever engine you chose: the Maplibre example imports `maplibre-gl/dist/maplibre-gl.css`, the Mapbox example imports `mapbox-gl/dist/mapbox-gl.css`. Import path and stylesheet are a single decision, and you make it before the first prop means anything.

The repository tests that pairing instead of assuming it. The root package.json pins two Mapbox generations under npm aliases at the same time, `"mapbox-gl-v1": "npm:[email protected]"` and `"mapbox-gl-v3": "npm:[email protected]"`, so one component surface is built against a 1.x engine and a 3.x engine. Nothing in the README says which props changed between those two lines. That mapping lives on the docs site or in the files under `test/`, and it is where you end up the first time a behaviour does not match what the example implied.

Nothing draws until mapStyle and a token are supplied

The wrapper ships no basemap. Both examples hand the Map component an `initialViewState` object holding longitude, latitude and zoom, plus a `style` box of 600 by 400, and then differ in where the pixels come from. The Mapbox example passes `mapStyle="mapbox://styles/mapbox/streets-v9"` together with a `mapboxAccessToken` prop. The Maplibre example passes a full `https://api.maptiler.com/maps/streets/style.json?key=<Maptiler access token>` URL instead.

The README documents no loading state, no message for a missing token and no retry when the style request fails. The Maplibre form also puts your tile key inside a URL string that lives in a prop, which is a decision to make before the first commit rather than after the key turns up in a public bundle.

Installing the maplibre pair and rendering a first Map

`react >= 16.3` is the only requirement stated, and the engine is the first thing to settle, because the two install lines pull different renderers and your import path has to match the one you installed.

sh
# Using Maplibre
npm install react-map-gl maplibre-gl

The Mapbox route has the same two-package shape:

sh
# Using Mapbox
npm install react-map-gl mapbox-gl

The first render is one component, with no store, no provider and no global CSS reset:

js
// Using Maplibre
import * as React from 'react';
import Map from 'react-map-gl/maplibre';
import 'maplibre-gl/dist/maplibre-gl.css';

function App() {
  return (
    <Map
      initialViewState={{
        longitude: -122.4,
        latitude: 37.8,
        zoom: 14
      }}
      style={{width: 600, height: 400}}
      mapStyle="https://api.maptiler.com/maps/streets/style.json?key=<Maptiler access token>"
    />
  );
}

In the example, size comes from the `style` prop.

The README stops at Map and defers the rest of the API

One component, two engines, two install lines, about eighty words of prose. Everything past that lives elsewhere: the Getting Started guide, the Design Philosophy page at `docs/README.md#design-philosophy`, and the online documentation linked from the header.

That has a direct cost when you are evaluating the package. Markers, popups, overlays and camera transitions are not named in the README, so a reader shopping for any of them has no way to confirm from the repository that they exist, which props they take, or which events they emit. The layout points at the answer without stating it: `examples/get-started`, `examples/mapbox` and `examples/maplibre` are the worked cases, and `docs/` and `website/` are the source of the published site. A two-minute evaluation ends in someone else's documentation, and the import path you committed to gets chosen before you read the API you chose it for.

React 18 is what the repo installs, 16.3 is what it asks for

The stated floor is `react >= 16.3`. The toolchain next to it is built on something narrower: the devDependencies ask for `"react": "^18.0.0"`, `"react-dom": "^18.0.0"`, `"@types/react": "^18.0.0"` and `"@types/react-dom": "^18.0.0"`, and the examples in `examples/` are written against those.

That gap is not a defect by itself, but it tells you what the version range is worth. Nothing in the published test setup runs the components against 16.3, 16.x or 17, so a project pinned below React 18 sits outside whatever the repository exercises. The rest of the test stack is pinned just as tightly, with `"jsdom": "^16.0.0"`, `"vitest": "^4.0.18"` and `"@vitest/coverage-v8": "^4.0.18"`, and a `.nvmrc` file at the root fixing the Node version for everyone who works on the library. If you are on an older React line, read the Getting Started guide before treating `>= 16.3` as a compatibility promise.

Browser rendering sits outside the pre-commit hook

The build runs on ocular and vitest, and the script names say exactly what each level covers: `npm test` runs `ocular-test node headless`, `npm run test-browser` runs `ocular-test browser`, `npm run test-fast` runs `ocular-build && ocular-test node`. The `pre-commit` field in package.json is wired to `test-fast`, so the map canvas is never opened before a commit lands on this repository.

Browser coverage also needs a binary npm does not fetch for you. The script `playwright:install` runs `playwright install chromium`, and `"playwright": "^1.58.0"` is the client half of that pair. The first person to touch anything visual runs the install script by hand, and a green pre-commit here says nothing about rendering, because the hook it runs never rendered anything.

Three 8.1.x releases in 2026, on top of an engine you do not control

The release record looks regular: v8.1.1 on 2026-04-11, v8.1.2 on 2026-07-29 and v8.1.3 on 2026-09-02, with the last push on 2026-10-24 and the repository not archived. The gaps are uneven, three and a half months and then five weeks, so a quarterly upgrade assumption fits the record better than a weekly one.

The version boundary that matters sits one layer down. This is a component layer, so its 8.x number says nothing about which mapbox-gl or maplibre-gl it expects, and the repository keeps two Mapbox generations in devDependencies for that reason. Working on the library is heavier than installing it: it is a workspace with `"workspaces": ["modules/*"]`, a packageManager pinned to [email protected] with an integrity hash, a build of `ocular-clean && ocular-build`, publishing through `ocular-publish version-only-prod`, and both `biome.jsonc` and a `.prettierrc` sitting at the root while linting runs through `ocular-lint`. The root package.json marks itself `"private": true` and declares `"license": "MIT"`, and the library states it is part of vis.gl, an OpenJS Foundation project.

Editorial conclusion

Adopt react-map-gl when you have already chosen mapbox-gl or maplibre-gl and want React props instead of engine callbacks. Skip it if you need a documented marker, popup or draw API and will not read the external docs, or if you are still shopping for a basemap. Before writing any of it, open docs/README.md#design-philosophy and confirm the entry point you plan to import matches the engine version in your lockfile.

Frequently asked questions

How do I install react-map-gl?

Install it next to the engine you want: `npm install react-map-gl maplibre-gl` for the MapLibre route or `npm install react-map-gl mapbox-gl` for the Mapbox route. The README states `react >= 16.3` as the only requirement.

What is react-map-gl?

It is a suite of React components that provides a React API for mapbox-gl or maplibre-gl. The components come in two entry points, `react-map-gl/mapbox` and `react-map-gl/maplibre`, so you pick the engine rather than the library.

Is react-map-gl free?

The repository root package.json declares `"license": "MIT"`. Running the map is a separate question: the examples depend on a Mapbox access token or on a Maptiler access key inside the style URL, and no basemap ships with the package.

react-map-gl vs Leaflet: what is the difference in approach?

react-map-gl is a component layer over mapbox-gl or maplibre-gl, not a renderer of its own, and the README names neither Leaflet nor any other alternative. The real comparison is between the wrapper and driving mapbox-gl or maplibre-gl directly, where the map instance and its state live outside React.

Do I need react-map-gl if I already use mapbox-gl?

If you want React props instead of the engine's own callbacks, yes, that is what the package is for. The Mapbox route imports from `react-map-gl/mapbox`, requires `mapbox-gl` alongside it and takes a `mapboxAccessToken` prop plus a `mapStyle` such as `mapbox://styles/mapbox/streets-v9`.

Official sources

  1. Issues
  2. Project website
  3. README
  4. Releases
  5. visgl/react-map-gl on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/visgl-react-map-gl.svg)](https://hysenlabs.com/projects/visgl-react-map-gl)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/visgl-react-map-gl.svg)](https://hysenlabs.com/projects/visgl-react-map-gl)

Was this useful?