Navigation¶
Starter Template uses navigation3 with Koin.
All navigation logic lives inside the features/navigation module.
1. Define Screens¶
Example:
| features/navigation/src/commonMain/.../screens/AuthScreens.kt | |
|---|---|
Rules
- Must be
@Serializable - Must extend
NavKey* Usesealed classper feature
2. Register Screens for Serialization¶
Add the screen to the back stack configuration:
| features/navigation/src/commonMain/.../StarterBackStack.kt | |
|---|---|
State Restoration
If a screen is not registered using subclass(...), state restoration will fail.
3. Define Navigation Routes (Koin)¶
| composeApp/src/commonMain/.../core/navigation/NavigationModule.kt | |
|---|---|
Custom Module
You can also create a custom module inside your feature di package,
don't forget to include it inside initKoin
4. Navigating Between Screens¶
Get navigator:
Available methods:
navigator.navigateTo(route)
navigator.popAndNavigate(route)
navigator.popAllAndNavigate(route)
navigator.navigateOrBringToTop(route)
navigator.navigateUp()
Example:
5. Changing Initial Screen¶
You can change the initial (starting) screen from App.kt.
By default, navigation starts from StarterScreens.Splash.
To change it, update the first parameter of StarterNavigation.
For example, to start directly from SignIn:
Keeping Splash → Onboarding → Your Screen Flow¶
If you want to keep the default flow:
You can control it inside the navigation module.
Navigation Flow
- Create screen (extend
NavKey) - Register in
StarterBackStack - Add route in
NavigationModuleor custom module - Use
StarterNavigatorto navigate - Change
inital screenif needed
Navigation is type-safe, serializable, and works across Compose Multiplatform.