Skip to Content
MapQuest SDK
Hooks

useNavigationSession

const session: NavigationSession | null = useNavigationSession()

Observe the active trip from inside Navigation or under the same Navigation.Provider as the guidance screen. Reading the session doesn't start guidance or location updates.

Return Values

session is the active trip, or null when idle. Position updates do not change the returned session; for a live location readout, use useCurrentPosition.

Example

Pair the session with useNavigation to show an end-trip button only during guidance:

import { useNavigation, useNavigationSession } from '@mapquest/sdk'
import { Button } from 'react-native'

export function EndTripButton() {
  const session = useNavigationSession()
  const navigation = useNavigation()
  if (!session) return null
  return <Button title="End trip" onPress={navigation.stopNavigation} />
}

On this page