This guide explains how to set up the React Native Navigation SDK in an Expo app.
The package ships an Expo config plugin
that applies the native setup during npx expo prebuild.
- Expo SDK 58 or later. Earlier SDKs ship a React Native version below this package's minimum; see React Native Compatibility.
- A development build.
Expo Go cannot load this package's native code, so start the app with
npx expo run:androidandnpx expo run:ios, or build it with EAS Build.
Install the package and expo-build-properties:
npx expo install @googlemaps/react-native-navigation-sdk expo-build-propertiesAdd the required settings to the expo object in app.json, keeping the
fields your app already has:
{
"expo": {
"ios": {
"deploymentTarget": "17.0",
"infoPlist": {
"NSLocationWhenInUseUsageDescription": "Navigation needs your location.",
"NSLocationAlwaysAndWhenInUseUsageDescription": "Navigation needs your location.",
"NSMotionUsageDescription": "Used to improve navigation features.",
"UIBackgroundModes": ["location", "audio"]
}
},
"plugins": [
"@googlemaps/react-native-navigation-sdk",
["expo-build-properties", { "android": { "kotlinVersion": "2.3.21" } }]
]
}
}npx expo install may already have added expo-build-properties to plugins
without options; keep a single entry with the Kotlin version. The override is
required because the Navigation SDK needs Kotlin Gradle Plugin 2.3.0 or later;
see the Migration Guide.
Set the API keys in ios.config.googleMapsApiKey and
android.config.googleMaps.apiKey. Expo writes them to Info.plist as
GMSApiKey and to AndroidManifest.xml. To read them from environment
variables, add an app.config.js that extends app.json:
module.exports = ({ config }) => ({
...config,
ios: {
...config.ios,
config: { googleMapsApiKey: process.env.GOOGLE_MAPS_IOS_API_KEY },
},
android: {
...config.android,
config: { googleMaps: { apiKey: process.env.GOOGLE_MAPS_ANDROID_API_KEY } },
},
});Then generate the native projects:
npx expo prebuild --cleanThe infoPlist usage descriptions only provide the text of the iOS permission
prompt. The app requests location permission at runtime before it initializes
navigation; see
Requesting and handling permissions.
In an Expo app, expo-location can request it:
npx expo install expo-locationimport * as Location from 'expo-location';
const { granted } = await Location.requestForegroundPermissionsAsync();The plugin applies the native setup that Expo's app config does not cover:
- iOS: adds
import GoogleMapstoAppDelegate.swiftand passes theInfo.plistGMSApiKeyvalue toGMSServices.provideAPIKeyat launch. - Android: enables Jetifier in
gradle.properties, and enables core library desugaring withdesugar_jdk_libs_nioinapp/build.gradle.
npx expo prebuild fails with an error from the plugin when an API key is not
set, or when it cannot find where to add its code in AppDelegate.swift. The
plugin supports the Swift AppDelegate and the Groovy app/build.gradle that
Expo SDK 58 generates.
Other packages that depend on the Google Maps SDK, such as react-native-maps,
may conflict with this package; see
Compatibility with other libraries.
If your project commits its ios and android folders instead of generating
them with npx expo prebuild, the plugin does not run. Follow the
Android and iOS setup in the README
instead.