# Do-It-Yourself Compose Multiplatform Navigation with Decompose

DevFeed: [Do-It-Yourself Compose Multiplatform Navigation with Decompose](<https://devfeed.tech/articles/do-it-yourself-compose-multiplatform-navigation-with-decompose-25916.md>)

Original publisher: [Read original article](<https://proandroiddev.com/diy-compose-multiplatform-navigation-with-decompose-94ac8126e6b5?source=rss-43bae76e8f81------2>)

Author: Isuru Rajapakse

Published: 2023-02-09T09:02:35Z

Content type: tutorial

Language: en

Sources: [Stories by Isuru Rajapakse on Medium](<https://devfeed.tech/sources/stories-by-isuru-rajapakse-on-medium.md>)

Topics: [compose-multiplatform](<https://devfeed.tech/topics/compose-multiplatform.md>), [navigation](<https://devfeed.tech/topics/navigation.md>), [Android](<https://devfeed.tech/topics/android.md>), [implementation](<https://devfeed.tech/topics/implementation.md>), [Processes](<https://devfeed.tech/topics/processes.md>), [business logic](<https://devfeed.tech/topics/business-logic.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [business-logic](<https://devfeed.tech/tags/business-logic.md>), [component](<https://devfeed.tech/tags/component.md>), [compose-multiplatform](<https://devfeed.tech/tags/compose-multiplatform.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [multiplatform](<https://devfeed.tech/tags/multiplatform.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [process](<https://devfeed.tech/tags/process.md>)

## AI overview

A tutorial on building Compose Multiplatform navigation with Decompose for Android and desktop. It explains how to share navigation logic, retain and scope ViewModels, and restore ViewModel state after process death while using a custom architecture.

## Source excerpt

How to survive configuration changes, survive process death and scope ViewModels without going all-in with Decompose 🫢 Decompose recently went 1.0.0 🙌. I think it's a good opportunity to share my specific use case with Decompose where I use it to share navigation logic between Android and Desktop, without going all in with Decompose's Component pattern. Here are some of the problems you would run into - in extracting the navigation to the shared code Abstraction of common navigation. Retaining and scoping your view models Restoring the view models state after the process death. Doesn't Decompose solve all these problems? Why not go all in? This was really just a preference. I wanted to do my own architecture for my app and an inheritance-based component approach wasn't my forte. Luckily Decompose allows you to use parts of it and couple your navigation with business logic (if you want to). Decompose provides you with extensive customisation options to tailor the library to your needs. That's what I ended up doing at the end An Update! 📰 I've decided to publish the implementations of this article as a library called Decompose-Router. This should save you some time if you want to implement this on your own app. If you don't care about the implementation details and just want to use the library, head over there. GitHub - xxfast/Decompose-Router: A Compose-multiplatform navigation library that leverage Decompose to create an API inspired by Conductor The Goal 🥅 This is what we will be working towards. @Parcelize sealed class Screen: Parcelable { object List : Screen() data class Details(val detail: String) : Screen() } @Composable fun ListDetailScreen() { val router: Router<Screen> = rememberRouter(listOf(List)) RoutedContent( router = router, animation = stackAnimation(slide()), ) { screen -> when (screen) { List -> ListScreen(onSelect { detail -> router.push(detail) } ) is Details -> DetailsScreen(screen.detail) } } } @Composable fun ListScreen(onSelect: (detail: Stri