# Route Requests

Send all route requests through `NBNavigation.fetchRoute`. The method uses the current _RoutingConfig_ to control online, offline and hybrid routing behavior. `RouteFetchResult.source` can be used to report the actual source at any time.

Request a route through _NBNavigation_:

```swift
let options = NavigationRouteOptions(
    waypoints: waypoints,
    profile: NBNavigationMode.car
)

let result = try await NBNavigation.fetchRoute(options: options)
let routes = result.routes
print("route source=\(result.source)")

// Pass routes to the existing Default UI or custom navigation flow.
```

To override the strategy for one request, call `fetchRoute(options:routingConfig:)`. This does not modify the process-wide configuration. Callback-based integrations can use:

```swift
NBNavigation.fetchRoute(options:completion:)
```

Or

```swift
NBNavigation.fetchRoute(options:completionHandler:).
```

| RouteMode | Behavior |
| --- | --- |
| `onlineOnly` | Uses online routing only. The request fails if the network is unavailable or the online request fails. No offline fallback is attempted. |
| `offlineOnly` | Uses offline routing only. The offline engine must be initialized and required routing data must be available. No online fallback is attempted. |
| `onlinePreferred` | Uses online routing first when the network is reachable. If the online request fails or times out, offline routing is attempted only when the offline engine was ready when the request started. If online routing is unavailable but offline routing is ready, the request starts directly with offline routing. |
| `offlinePreferred` | Uses offline routing first when the offline engine is ready. If the offline request fails or times out, online routing is attempted only when the network was reachable when the request started. If offline routing is unavailable but online routing is reachable, the request starts directly with online routing. |
| `smart` | Selects from the sources available when the request starts. When both sources are available, it tries online routing first and then offline routing. When only one source is available, it uses that source. The request fails when neither source is available. |

_offlineOnly_ succeeds only after the offline engine is initialized and routing data for the required region is downloaded. Map-tile availability does not determine whether route calculation succeeds, but it does determine whether the map displays correctly without a network connection.
