Skip to main content

Note that those instructions applies to the 10.2.* versions of @rnmapbox/maps.

Configure credentials

Before installing @rnmapbox/maps you'll need to get your Mapbox access token.

To grab your token, open up a browser and go to your account's tokens page: https://console.mapbox.com/account/access-tokens/

On the top of your token list, copy your Default Public Token. The public token starts with pk.ey.

For more details, see Configure Credentials on mapbox.com.

Install

npm install @rnmapbox/maps

Configure @rnmapbox/maps

Update your podfile

Add the following to your ios/Podfile

pre_install do |installer|
$RNMapboxMaps.pre_install(installer)
end

post_install do |installer|
$RNMapboxMaps.post_install(installer)
# ... other post install hooks
end

Rebuild

React Native Mapbox Maps cannot be used in the "Expo Go" app, because it requires custom native code.

Next, if you are not using EAS Build then you must rebuild your app as described in the "Adding custom native code" guide to include the config plugin changes. If this command isn't run, you'll not be able use @rnmapbox/maps.

expo prebuild --clean

Customizing Mapbox Version

@rnmapbox/maps 10.2 defaults to Mapbox Maps SDK 11.0.*.

Note: Mapbox Maps SDK v10 is now deprecated. We recommend using v11 for new projects and upgrading existing projects to v11.

Using V10 (Deprecated)

If you need to use the deprecated 10.16.* version, you can configure it according to your platform:

Add RNMapboxMapsVersion to the @rnmapbox/maps config plugin to the plugins array of your app.{json,config.js,config.ts}:

{
"expo": {
"plugins": [
[
"@rnmapbox/maps",
{
...
"RNMapboxMapsVersion": "10.16.4"
}
]
]
}
}

Advanced - using non default version

It's possible to overwrite the native SDK version with RNMapboxMapsVersion. However, you should revise this when upgrading @rnmapbox/maps as future releases might not support the version you set.

To use a specific v11 version, follow the instructions above for customizing the Mapbox version, specifying your desired 11.* version (e.g., 11.0.0, 11.1.0, etc.).

Configure permissions for location access

If you want to show the location puck on the map with the LocationPuck component, you can use the expo-location plugin to configure the required NSLocationWhenInUseUsageDescription property. Install the plugin with npx expo install expo-location and add its config plugin to the plugins array of your app.{json,config.js,config.ts}:

{
"expo": {
"plugins": [
[
"expo-location",
{
"locationWhenInUsePermission": "Show current location on map."
}
]
]
}
}