Stay organized with collections
Save and categorize content based on your preferences.
Top-level functions summary
Top-level functions
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-07-10 UTC.
[null,null,["Last updated 2025-07-10 UTC."],[],[],null,["# androidx.hilt.lifecycle.viewmodel.compose\n=========================================\n\nTop-level functions summary\n---------------------------\n\n|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `inline VM` | `@`[Composable](/reference/kotlin/androidx/compose/runtime/Composable) `\u003cVM : `[ViewModel](/reference/kotlin/androidx/lifecycle/ViewModel)`\u003e `[hiltViewModel](/reference/kotlin/androidx/hilt/lifecycle/viewmodel/compose/package-summary#hiltViewModel(androidx.lifecycle.ViewModelStoreOwner,kotlin.String))`(` ` viewModelStoreOwner: `[ViewModelStoreOwner](/reference/kotlin/androidx/lifecycle/ViewModelStoreOwner)`,` ` key: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` `)` Returns an existing [HiltViewModel](https://dagger.dev/api/latest/dagger/hilt/android/lifecycle/HiltViewModel) -annotated [ViewModel](/reference/kotlin/androidx/lifecycle/ViewModel) or creates a new one scoped to the current [ViewModelStoreOwner](/reference/kotlin/androidx/lifecycle/ViewModelStoreOwner). |\n| `inline VM` | `@`[Composable](/reference/kotlin/androidx/compose/runtime/Composable) `\u003cVM : `[ViewModel](/reference/kotlin/androidx/lifecycle/ViewModel)`, VMF : `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?\u003e `[hiltViewModel](/reference/kotlin/androidx/hilt/lifecycle/viewmodel/compose/package-summary#hiltViewModel(androidx.lifecycle.ViewModelStoreOwner,kotlin.String,kotlin.Function1))`(` ` viewModelStoreOwner: `[ViewModelStoreOwner](/reference/kotlin/androidx/lifecycle/ViewModelStoreOwner)`,` ` key: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?,` ` noinline creationCallback: (VMF) `-\u003e` VM` `)` Returns an existing [HiltViewModel](https://dagger.dev/api/latest/dagger/hilt/android/lifecycle/HiltViewModel) -annotated [ViewModel](/reference/kotlin/androidx/lifecycle/ViewModel) with an @AssistedInject-annotated constructor or creates a new one scoped to the current [ViewModelStoreOwner](/reference/kotlin/androidx/lifecycle/ViewModelStoreOwner). |\n\nTop-level functions\n-------------------\n\n### hiltViewModel\n\nArtifact: [androidx.hilt:hilt-lifecycle-viewmodel-compose](/jetpack/androidx/releases/hilt) \n[View Source](https://cs.android.com/search?q=file:androidx/hilt/lifecycle/viewmodel/compose/HiltViewModel.kt+function:hiltViewModel) \n\n```\n@Composable\ninline fun \u003cVM : ViewModel\u003e hiltViewModel(\n viewModelStoreOwner: ViewModelStoreOwner = checkNotNull(LocalViewModelStoreOwner.current) {\n \"No ViewModelStoreOwner was provided via LocalViewModelStoreOwner\"\n },\n key: String? = null\n): VM\n```\n\nReturns an existing [HiltViewModel](https://dagger.dev/api/latest/dagger/hilt/android/lifecycle/HiltViewModel) -annotated [ViewModel](/reference/kotlin/androidx/lifecycle/ViewModel) or creates a new one scoped to the current [ViewModelStoreOwner](/reference/kotlin/androidx/lifecycle/ViewModelStoreOwner). \n\n### hiltViewModel\n\nArtifact: [androidx.hilt:hilt-lifecycle-viewmodel-compose](/jetpack/androidx/releases/hilt) \n[View Source](https://cs.android.com/search?q=file:androidx/hilt/lifecycle/viewmodel/compose/HiltViewModel.kt+function:hiltViewModel) \n\n```\n@Composable\ninline fun \u003cVM : ViewModel, VMF : Any?\u003e hiltViewModel(\n viewModelStoreOwner: ViewModelStoreOwner = checkNotNull(LocalViewModelStoreOwner.current) {\n \"No ViewModelStoreOwner was provided via LocalViewModelStoreOwner\"\n },\n key: String? = null,\n noinline creationCallback: (VMF) -\u003e VM\n): VM\n```\n\nReturns an existing [HiltViewModel](https://dagger.dev/api/latest/dagger/hilt/android/lifecycle/HiltViewModel) -annotated [ViewModel](/reference/kotlin/androidx/lifecycle/ViewModel) with an @AssistedInject-annotated constructor or creates a new one scoped to the current [ViewModelStoreOwner](/reference/kotlin/androidx/lifecycle/ViewModelStoreOwner)."]]