Skip to content
React friendly API wrapper around MapboxGL JS
JavaScript CSS Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Update release branch links Jan 7, 2020
examples Fix website build scripts (#981) Jan 7, 2020
flow-typed/npm Viewport flyTo Interpolation: add support for auto duration and other… Sep 6, 2019
ocular add geolocate control (#724) Feb 20, 2019
scripts add release script (#754) May 31, 2019
src Deep compare source props (#985) Jan 13, 2020
test Fix control icons when used with mapbox-gl@>=1.6 (#967) Dec 30, 2019
website Fix website build scripts (#981) Jan 7, 2020
.editorconfig Upgrade uber-standard and use typical .editorconfig file. Jan 5, 2016
.eslintignore Buble+webpack2 (#169) Mar 7, 2017
.eslintrc.js Upgrade dev tools to ocular (#780) May 8, 2019
.flowconfig Set up flow (#651) Nov 5, 2018
.gitignore Dev tools setup (#803) May 31, 2019
.nycrc Avoid mutating style objects during normalization (#926) Oct 29, 2019
.prettierrc Upgrade dev tools to ocular (#780) May 8, 2019
.travis.yml Dev tools setup (#803) May 31, 2019 5.2.0 Jan 7, 2020
LICENSE Remove unrelated licenses from LICENSE (#359) Sep 19, 2017 Migrate build badge from to (#781) May 13, 2019 Add `transformRequest` prop to map components. (#426) Dec 19, 2017
aliases.js Upgrade dev tools to ocular (#780) May 8, 2019
babel.config.js Add babel react preset and migrate react components to jsx (#875) Sep 16, 2019
index.html Fix flow build process Mar 24, 2017
ocular-dev-tools.config.js Dev tools setup (#803) May 31, 2019
package.json Bump mjolnir.js dependency (#990) Jan 13, 2020
webpack.config.js Update dev setup (#976) Jan 2, 2020
yarn.lock Bump mjolnir.js dependency (#990) Jan 13, 2020

version build downloads

react-map-gl | Docs

React Components Suite for Mapbox GL JS.

In addition to exposing MapboxGL functionality to React apps, react-map-gl also integrates seamlessly with

Before You Begin

This library provides convenient wrappers around initializing and (to some degree) tracking the state of a Mapbox WebGL map. Because most of the functionality of Mapbox's JS API depends on the use of HTML5 canvases and WebGL, which React is not built to manipulate, the React component does not mirror all the functionality of Mapbox GL JS's Map class. You may access the native Mapbox API exposed by the getMap() function in this library. However, proceed with caution as calling the native APIs may break the connection between the React layer props and the underlying map state.


Using react-map-gl requires react >= 16.3.

npm install --save react-map-gl


import {Component} from 'react';
import ReactMapGL from 'react-map-gl';

class Map extends Component {

  state = {
    viewport: {
      width: 400,
      height: 400,
      latitude: 37.7577,
      longitude: -122.4376,
      zoom: 8

  render() {
    return (
        onViewportChange={(viewport) => this.setState({viewport})}

About Mapbox Tokens

To show maps from a service such as Mapbox you will need to register on their website in order to retrieve an access token required by the map component, which will be used to identify you and start serving up map tiles. The service will be free until a certain level of traffic is exceeded.

There are several ways to provide a token to your app, as showcased in some of the example folders:

  • Provide a mapboxApiAccessToken prop to the map component
  • Set the MapboxAccessToken environment variable (or set REACT_APP_MAPBOX_ACCESS_TOKEN if you are using Create React App)
  • Provide it in the URL, e.g ?access_token=TOKEN
  • Provide mapboxApiUrl prop to the map component to override the default mapbox API URL

But we would recommend using something like dotenv and put your key in an untracked .env file, that will then expose it as a process.env variable, with much less leaking risks.


See developer guide.

You can’t perform that action at this time.