# NavOptionsBuilder

Artifact: [androidx.navigation:navigation-common](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/NavOptionsBuilder.+class:androidx.navigation.NavOptionsBuilder) Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

*** ** * ** ***

Common/AllAndroid/JVMJavaScript
- Cmn

  ```
  @NavOptionsDsl
  class NavOptionsBuilder
  ```

*** ** * ** ***

DSL for constructing a new `https://developer.android.com/reference/kotlin/androidx/navigation/NavOptions`

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/navigation/NavOptionsBuilder#NavOptionsBuilder()()` | Cmn android |

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/navigation/NavOptionsBuilder#anim(kotlin.Function1)(animBuilder: https://developer.android.com/reference/kotlin/androidx/navigation/AnimBuilder.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Sets any custom Animation or Animator resources that should be used. | android |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/navigation/NavOptionsBuilder#popUpTo(kotlin.Function1)(noinline popUpToBuilder: https://developer.android.com/reference/kotlin/androidx/navigation/PopUpToBuilder.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Pop up to a given destination before navigating. | Cmn android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/navigation/NavOptionsBuilder#popUpTo(kotlin.Int,kotlin.Function1)(id: @https://developer.android.com/reference/kotlin/androidx/annotation/IdRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, popUpToBuilder: https://developer.android.com/reference/kotlin/androidx/navigation/PopUpToBuilder.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Pop up to a given destination before navigating. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/navigation/NavOptionsBuilder#popUpTo(kotlin.reflect.KClass,kotlin.Function1)(route: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<T>, popUpToBuilder: https://developer.android.com/reference/kotlin/androidx/navigation/PopUpToBuilder.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Pop up to a given destination before navigating. | Cmn android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/navigation/NavOptionsBuilder#popUpTo(kotlin.Any,kotlin.Function1)(route: T, popUpToBuilder: https://developer.android.com/reference/kotlin/androidx/navigation/PopUpToBuilder.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Pop up to a given destination before navigating. | Cmn android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/navigation/NavOptionsBuilder#popUpTo(kotlin.String,kotlin.Function1)(route: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, popUpToBuilder: https://developer.android.com/reference/kotlin/androidx/navigation/PopUpToBuilder.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Pop up to a given destination before navigating. | Cmn android |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/navigation/NavOptionsBuilder#launchSingleTop()` Whether this navigation action should launch as single-top (i.e., there will be at most one copy of a given destination on the top of the back stack). | Cmn android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/navigation/NavOptionsBuilder#popUpTo()` **This property is deprecated.** Use the popUpToId property. | android |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/IdRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/navigation/NavOptionsBuilder#popUpToId()` Returns the current destination that the builder will pop up to. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/navigation/NavOptionsBuilder#popUpToRoute()` The destination to pop up to before navigating. | Cmn android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<*>?` | `https://developer.android.com/reference/kotlin/androidx/navigation/NavOptionsBuilder#popUpToRouteClass()` The destination to pop up to before navigating. | Cmn android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | `https://developer.android.com/reference/kotlin/androidx/navigation/NavOptionsBuilder#popUpToRouteObject()` The destination to pop up to before navigating. | Cmn android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/navigation/NavOptionsBuilder#restoreState()` Whether this navigation action should restore any state previously saved by `https://developer.android.com/reference/kotlin/androidx/navigation/PopUpToBuilder#saveState()` or the `popUpToSaveState` attribute. | Cmn android |

## Public constructors

### NavOptionsBuilder

Cmn android Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
NavOptionsBuilder()
```

## Public functions

### anim

android Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
fun anim(animBuilder: AnimBuilder.() -> Unit): Unit
```

Sets any custom Animation or Animator resources that should be used.

Note: Animator resources are not supported for navigating to a new Activity

### popUpTo

Cmn android

```
inline fun <T : Any> popUpTo(noinline popUpToBuilder: PopUpToBuilder.() -> Unit = {}): Unit
```

Pop up to a given destination before navigating. This pops all non-matching destination routes from the back stack until the destination with a matching route is found.

| Parameters |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | route from a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html` for the destination |
| `noinline popUpToBuilder: https://developer.android.com/reference/kotlin/androidx/navigation/PopUpToBuilder.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html = {}` | builder used to construct a popUpTo operation |

### popUpTo

android Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
fun popUpTo(id: @IdRes Int, popUpToBuilder: PopUpToBuilder.() -> Unit = {}): Unit
```

Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.

### popUpTo

Cmn android Added in [2.9.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.9.0)

```
fun <T : Any> popUpTo(route: KClass<T>, popUpToBuilder: PopUpToBuilder.() -> Unit): Unit
```

Pop up to a given destination before navigating. This pops all non-matching destination routes from the back stack until the destination with a matching route is found.

| Parameters |
|---|---|
| `route: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<T>` | the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html` of the destination `https://developer.android.com/reference/kotlin/androidx/navigation/NavOptionsBuilder#popUpTo(kotlin.reflect.KClass,kotlin.Function1)` |
| `popUpToBuilder: https://developer.android.com/reference/kotlin/androidx/navigation/PopUpToBuilder.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | builder used to construct a popUpTo operation |

### popUpTo

Cmn android Added in [2.8.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.8.0)

```
fun <T : Any> popUpTo(route: T, popUpToBuilder: PopUpToBuilder.() -> Unit = {}): Unit
```

Pop up to a given destination before navigating. This pops all non-matching destination routes from the back stack until the destination with a matching route is found.

| Parameters |
|---|---|
| `route: T` | route from a Object for the destination |
| `popUpToBuilder: https://developer.android.com/reference/kotlin/androidx/navigation/PopUpToBuilder.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html = {}` | builder used to construct a popUpTo operation |

### popUpTo

Cmn android Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
fun popUpTo(route: String, popUpToBuilder: PopUpToBuilder.() -> Unit = {}): Unit
```

Pop up to a given destination before navigating. This pops all non-matching destination routes from the back stack until the destination with a matching route is found.

| Parameters |
|---|---|
| `route: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | route for the destination |
| `popUpToBuilder: https://developer.android.com/reference/kotlin/androidx/navigation/PopUpToBuilder.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html = {}` | builder used to construct a popUpTo operation |

## Public properties

### launchSingleTop

Cmn android Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
var launchSingleTop: Boolean
```

Whether this navigation action should launch as single-top (i.e., there will be at most one copy of a given destination on the top of the back stack).

This functions similarly to how [android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP](https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_SINGLE_TOP) works with activities.

### popUpTo

android Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0) Deprecated in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
var popUpTo: Int
```

> [!CAUTION]
> **This property is deprecated.**   
> Use the popUpToId property.

The destination to pop up to before navigating. All non-matching destinations from the back stack up until this destination will also be popped.

### popUpToId

android Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
val popUpToId: @IdRes Int
```

Returns the current destination that the builder will pop up to.

### popUpToRoute

Cmn android Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
val popUpToRoute: String?
```

The destination to pop up to before navigating. All non-matching destinations from the back stack up until this destination will also be popped.

### popUpToRouteClass

Cmn android Added in [2.8.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.8.0)

```
val popUpToRouteClass: KClass<*>?
```

The destination to pop up to before navigating. All non-matching destinations from the back stack up until this destination will also be popped.

### popUpToRouteObject

Cmn android Added in [2.8.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.8.0)

```
val popUpToRouteObject: Any?
```

The destination to pop up to before navigating. All non-matching destinations from the back stack up until this destination will also be popped.

### restoreState

Cmn android Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
var restoreState: Boolean
```

Whether this navigation action should restore any state previously saved by `https://developer.android.com/reference/kotlin/androidx/navigation/PopUpToBuilder#saveState()` or the `popUpToSaveState` attribute. If no state was previously saved with the destination ID being navigated to, this has no effect.