> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/ios/ja/navigation/v2/llms.txt)

# Rerouting

Rerouting is when a new route is generated after the user's progress along a route has already begun. There are a few reasons rerouting happens including the user going off-route and the Navigation SDK determining there is a faster route to the next waypoint from the user's current location.

## Off-route detection

The Navigation SDK provides information about whether a user's device is on the route that was generated. If a user is off-route, you can provide additional instruction to the user and generate a new route.

The [`RouteController`](https://docs.mapbox.com/ios/navigation/api/2.21.0/Classes/RouteController.html)'s [`userIsOnRoute`](https://docs.mapbox.com/ios/navigation/api/2.21.0/Classes/RouteController.html#/c:@M@MapboxNavigation@objc(pl)Router(im)userIsOnRoute:) property uses the device location to check if a user is on or off the current route and returns a boolean.

By default, if a user is off-route, a new route is generated from their current location to the next waypoint. [`NavigationServiceDelegate.navigationService(_:willRerouteFrom:)`](https://docs.mapbox.com/ios/navigation/api/2.21.0/Classes/NavigationViewController.html#/c:@M@MapboxNavigation@objc(pl)NavigationServiceDelegate(im)navigationService:willRerouteFromLocation:) is called and `Notification.Name.routeControllerWillReroute` is posted after the SDK detects the need for a reroute but before receiving the new route. Then [`NavigationServiceDelegate.navigationService(_:didRerouteAlong:at:proactive:)`](https://docs.mapbox.com/ios/navigation/api/2.21.0/Classes/NavigationViewController.html#/c:@M@MapboxNavigation@objc(pl)NavigationServiceDelegate(im)navigationService:didRerouteAlongRoute:at:proactive:) is called and `Notification.Name.routeControllerDidReroute` is posted once you receive the new route. You can use these methods to customize built-in behavior and synchronize your application behavior with what's happening with navigation logic.

You can also preempt rerouting on a case-by-case basis using the [`NavigationServiceDelegate.navigationService(_:shouldRerouteFrom:)`](https://docs.mapbox.com/ios/navigation/api/2.21.0/Classes/NavigationViewController.html#/c:@M@MapboxNavigation@objc(pl)NavigationServiceDelegate(im)navigationService:shouldRerouteFromLocation:) delegate method.

## Faster-route detection

By default, the Navigation SDK checks for a faster route every two minutes by making a request to the Direction API and comparing the response to the current route.

You can customize the interval at which to check for a faster route by setting the [`RouteControllerProactiveReroutingInterval`](https://docs.mapbox.com/ios/navigation/api/2.21.0/Configuration.html#/s:16MapboxNavigation41RouteControllerProactiveReroutingIntervalSdvp) global variable. You can opt-out of faster-route detection by setting `navigationService.router.reroutesProactively` to `false`.

```swift
navigationService.router.reroutesProactively = false
```