Maps, ride-sharing, delivery tracking, weather, "find stores near me" — all of them start with the device's location. expo-location is the most-searched way to read GPS coordinates in an Expo app. This guide covers permissions, one-off reads, live tracking, and turning coordinates into an address.
Install
npx expo install expo-location
Add permission copy in app.json:
{
"expo": {
"plugins": [
["expo-location", {
"locationAlwaysAndWhenInUsePermission": "Allow $(PRODUCT_NAME) to use your location."
}]
]
}
}
Request permission and read the current position
import * as Location from "expo-location"
import { useEffect, useState } from "react"
import { Text, View } from "react-native"
export default function Where() {
const [coords, setCoords] = useState<Location.LocationObjectCoords | null>(null)
useEffect(() => {
;(async () => {
const { status } = await Location.requestForegroundPermissionsAsync()
if (status !== "granted") return
const location = await Location.getCurrentPositionAsync({})
setCoords(location.coords)
})()
}, [])
return (
<View>
<Text>
{coords ? `${coords.latitude}, ${coords.longitude}` : "Locating…"}
</Text>
</View>
)
}
Control accuracy
Higher accuracy costs battery and takes longer. Pick what your feature needs:
const location = await Location.getCurrentPositionAsync({
accuracy: Location.Accuracy.Balanced, // Lowest | Low | Balanced | High | Highest
})
Watch location in real time
For live tracking, subscribe with watchPositionAsync and clean up on unmount:
import { useEffect } from "react"
useEffect(() => {
let subscription: Location.LocationSubscription
;(async () => {
await Location.requestForegroundPermissionsAsync()
subscription = await Location.watchPositionAsync(
{ accuracy: Location.Accuracy.High, distanceInterval: 10 },
(loc) => console.log(loc.coords.latitude, loc.coords.longitude)
)
})()
return () => subscription?.remove()
}, [])
Turn coordinates into an address
const [place] = await Location.reverseGeocodeAsync({
latitude: 37.7749,
longitude: -122.4194,
})
console.log(place.city, place.region) // "San Francisco", "CA"
Gotchas
- Foreground vs background:
requestForegroundPermissionsAsynccovers most apps. Background tracking needs extra permissions and a config plugin, and app-store review scrutiny. - Always
remove()a watch subscription — leaving it running drains the battery. - Simulators let you fake a location (Xcode/Android Studio), which is handy for testing.
Next steps
Pair location with notifications for geo-reminders — see the expo-notifications guide — or cache places offline with expo-sqlite. See everything in the top 10 Expo SDK modules.