commonMain.captain.Router.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of captain-router-compose-core-jvm Show documentation
Show all versions of captain-router-compose-core-jvm Show documentation
A compose router that follows any type of navigator
The newest version!
package captain
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
@Composable
fun Router(
start: String = "/",
navigator: Navigator = BasicNavigator(start),
content: @Composable () -> Unit
) {
if (start != navigator.current().path) navigator.navigate(start)
CompositionLocalProvider(LocalNavigator provides navigator) {
content()
}
}