{"id":13658231,"url":"https://github.com/raamcosta/compose-destinations","last_synced_at":"2025-05-13T17:08:53.635Z","repository":{"id":37398504,"uuid":"402228168","full_name":"raamcosta/compose-destinations","owner":"raamcosta","description":"Annotation processing library for type-safe Jetpack Compose navigation with no boilerplate.","archived":false,"fork":false,"pushed_at":"2025-05-03T12:08:27.000Z","size":2626,"stargazers_count":3308,"open_issues_count":35,"forks_count":141,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-05-03T12:30:47.162Z","etag":null,"topics":["android","android-library","hacktoberfest","jetpack-compose","kotlin","kotlin-android","kotlin-library","ksp","navigation","safeargs"],"latest_commit_sha":null,"homepage":"https://composedestinations.rafaelcosta.xyz","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raamcosta.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":"rafaelamcosta","custom":"https://paypal.me/zkeme?country.x=PT\u0026locale.x=pt_PT"}},"created_at":"2021-09-01T23:17:50.000Z","updated_at":"2025-05-03T12:29:08.000Z","dependencies_parsed_at":"2023-11-21T00:43:17.095Z","dependency_job_id":"5baaf500-e988-423a-8eef-6e22b7af7c04","html_url":"https://github.com/raamcosta/compose-destinations","commit_stats":null,"previous_names":[],"tags_count":217,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raamcosta%2Fcompose-destinations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raamcosta%2Fcompose-destinations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raamcosta%2Fcompose-destinations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raamcosta%2Fcompose-destinations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raamcosta","download_url":"https://codeload.github.com/raamcosta/compose-destinations/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990468,"owners_count":21995774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","hacktoberfest","jetpack-compose","kotlin","kotlin-android","kotlin-library","ksp","navigation","safeargs"],"created_at":"2024-08-02T05:00:57.836Z","updated_at":"2025-05-13T17:08:48.601Z","avatar_url":"https://github.com/raamcosta.png","language":"Kotlin","funding_links":["https://buymeacoffee.com/rafaelamcosta","https://paypal.me/zkeme?country.x=PT\u0026locale.x=pt_PT"],"categories":["Multiplatform","Kotlin","Articles"],"sub_categories":["Multiplatform libraries","Navigation"],"readme":"[![Maven metadata URL](https://img.shields.io/maven-metadata/v?versionPrefix=1.11\u0026color=blue\u0026metadataUrl=https://s01.oss.sonatype.org/service/local/repo_groups/public/content/io/github/raamcosta/compose-destinations/core/maven-metadata.xml\u0026style=for-the-badge)](https://maven-badges.herokuapp.com/maven-central/io.github.raamcosta.compose-destinations/core)\n[![License Apache 2.0](https://img.shields.io/github/license/raamcosta/compose-destinations.svg?style=for-the-badge\u0026color=orange)](https://opensource.org/licenses/Apache-2.0)\n[![Android API](https://img.shields.io/badge/api-21%2B-brightgreen.svg?style=for-the-badge)](https://android-arsenal.com/api?level=21)\n[![kotlin](https://img.shields.io/github/languages/top/raamcosta/compose-destinations.svg?style=for-the-badge\u0026color=blueviolet)](https://kotlinlang.org/)\n\n\u003cp align=\"center\"\u003e\n   \u003cimg height=\"500\" src=\"/.idea/icon.svg\"/\u003e  \n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003e \n   \u003ca href=\"https://composedestinations.rafaelcosta.xyz\"\u003eCompose Destinations\u003c/a\u003e\n\u003c/h1\u003e\n\nA KSP library that processes annotations and generates code that uses Official Jetpack Compose Navigation under the hood. It hides the complex, non-type-safe and boilerplate code you would have to write otherwise. \u003c/br\u003e\nNo need to learn a whole new framework to navigate - most APIs are either the same as with the Jetpack Components or inspired by them.\n\n## V2 is here! 🙌\nPlease consider migrating to it and leaving feedback as GH issue or on our slack channel [#compose-destinations](https://kotlinlang.slack.com/archives/C06CS4UCQ10)!  \n * Migration guide: https://composedestinations.rafaelcosta.xyz/migrating-to-v2\n * V2 docs: https://composedestinations.rafaelcosta.xyz/v2\n\n\n## Main features 🧭\n- Typesafe navigation arguments\n- Simple but configurable navigation graphs setup\n- Navigating back with a result in a simple and type-safe way\n- Getting the navigation arguments from the `SavedStateHandle` (useful in ViewModels) and `NavBackStackEntry` in a type-safe way.\n- Navigation animations\n- Destination wrappers to allow reusing Compose logic on multiple screens\n- Bottom sheet screens\n- Easy deep linking to screens\n- Wear OS support (since versions 1.x.30!)\n- All you can do with Official Jetpack Compose Navigation but in a simpler safer way!\n\nFor a deeper look into all the features, check our [documentation website](https://composedestinations.rafaelcosta.xyz).\n\n## Basic Usage 🧑‍💻\n\n\u003e [!NOTE]  \n\u003e This readme is about v2. If you're now starting to use Compose Destinations, I strongly recommend using v2.\n\u003e If you really want to see basic v1 usage, [check it here](https://composedestinations.rafaelcosta.xyz/#basic-usage). \n\n### 1. Annotate your screen Composables with `@Destination\u003cRootGraph\u003e`:\n\n```kotlin\n@Destination\u003cRootGraph\u003e // sets this as a destination of the \"root\" nav graph\n@Composable\nfun ProfileScreen() { /*...*/ }\n```\n\n### 2. Add navigation arguments to the function declaration:\n\n```kotlin\n@Destination\u003cRootGraph\u003e\n@Composable\nfun ProfileScreen(\n   id: Int, // \u003c-- required navigation argument\n   groupName: String?, // \u003c-- optional navigation argument\n   isOwnUser: Boolean = false // \u003c-- optional navigation argument\n) { /*...*/ }\n```\n\n`Parcelable`, `Serializable`, `Enum` and classes annotated with [`@kotlinx.serialization.Serializable`](https://github.com/Kotlin/kotlinx.serialization) (as well as `Array`s and `ArrayList`s of these) work out of the box!\nYou can also make any other type a navigation argument type. Read about it [here](https://composedestinations.rafaelcosta.xyz/v2/arguments/navigation-arguments#custom-navigation-argument-types)\n\n\u003e [!TIP]  \n\u003e There is an alternative way to define the destination arguments in case you don't need to use them\ninside the Composable (as is likely the case when using ViewModel). Read more [here](https://composedestinations.rafaelcosta.xyz/v2/arguments/navigation-arguments#destination-navigation-arguments).\n\n### 3. Build the project\n   Or run ksp task (example: `./gradlew kspDebugKotlin`), to generate all the Destinations. With the above annotated composable, a `ProfileScreenDestination` file would be generated (that we'll use in step 4).\n\n### 4. Use the generated `[ComposableName]Destination`'s invoke method to navigate to it.\n   It will have the correct typed arguments.\n\n```kotlin\n@Destination\u003cRootGraph\u003e(start = true) // sets this as the start destination of the \"root\" nav graph\n@Composable\nfun HomeScreen(\n   navigator: DestinationsNavigator\n) {\n   /*...*/\n   navigator.navigate(ProfileScreenDestination(id = 7, groupName = \"Kotlin programmers\"))\n}\n```\n\n### 5. Finally, add the NavHost call:\n\n```kotlin\nDestinationsNavHost(navGraph = NavGraphs.root)\n```\n\u003e [!NOTE]  \n\u003e `NavGraphs` is a generated file that contains all navigation graphs. \n\u003e `root` here corresponds to the `\u003cRootGraph\u003e` we used in the above examples.\n\u003e You're also able to [define your own navigation graphs](https://composedestinations.rafaelcosta.xyz/v2/defining-navgraphs) to use instead of `\u003cRootGraph\u003e`.\n\nThis call adds all annotated Composable functions as destinations of the Navigation Host.\n\nThat's it! No need to worry about routes, `NavType`, bundles and strings. All that redundant and\nerror-prone code gets generated for you.\n\n## Setup 🧩\n\nCompose destinations is available via maven central.\n\n#### 1. Add the KSP plugin:\n\n\u003e **Note**: The version you chose for the KSP plugin depends on the Kotlin version your project uses. \u003c/br\u003e\nYou can check https://github.com/google/ksp/releases for the list of KSP versions, then pick the last release that matches your Kotlin version.\nExample:\nIf you're using `1.9.22` Kotlin version, then the last KSP version is `1.9.22-1.0.17`.\n\n\u003cdetails open\u003e\n  \u003csummary\u003egroovy - build.gradle(:module-name)\u003c/summary\u003e\n\n```gradle\nplugins {\n    //...\n    id 'com.google.devtools.ksp' version '1.9.22-1.0.17' // Depends on your kotlin version\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003ekotlin - build.gradle.kts(:module-name)\u003c/summary\u003e  \n\n```gradle\nplugins {\n    //...\n    id(\"com.google.devtools.ksp\") version \"1.9.22-1.0.17\" // Depends on your kotlin version\n}\n```\n\u003c/details\u003e\n\n#### 2. Add the dependencies:\n\nCompose Destinations has multiple active versions. \nThe higher one uses the latest versions for Compose and Navigation, while the others use only stable versions.\nChoose the one that matches your Compose version, considering this table:\n\n\u003ctable\u003e\n \u003ctr\u003e\n  \u003ctd\u003eCompose 1.1 (1.1.x)\u003c/td\u003e\u003ctd\u003e\u003cimg alt=\"Maven Central\" src=\"https://img.shields.io/maven-metadata/v?versionPrefix=1.5\u0026color=blue\u0026metadataUrl=https://s01.oss.sonatype.org/service/local/repo_groups/public/content/io/github/raamcosta/compose-destinations/core/maven-metadata.xml\u0026style=for-the-badge)](https://maven-badges.herokuapp.com/maven-central/io.github.raamcosta.compose-destinations/core)\"\u003e\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003eCompose 1.2 (1.2.x)\u003c/td\u003e\u003ctd\u003e\u003cimg alt=\"Maven Central\" src=\"https://img.shields.io/maven-metadata/v?versionPrefix=1.6\u0026color=blue\u0026metadataUrl=https://s01.oss.sonatype.org/service/local/repo_groups/public/content/io/github/raamcosta/compose-destinations/core/maven-metadata.xml\u0026style=for-the-badge)](https://maven-badges.herokuapp.com/maven-central/io.github.raamcosta.compose-destinations/core)\"\u003e\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003eCompose 1.3 (1.3.x)\u003c/td\u003e\u003ctd\u003e\u003cimg alt=\"Maven Central\" src=\"https://img.shields.io/maven-metadata/v?versionPrefix=1.7\u0026color=blue\u0026metadataUrl=https://s01.oss.sonatype.org/service/local/repo_groups/public/content/io/github/raamcosta/compose-destinations/core/maven-metadata.xml\u0026style=for-the-badge)](https://maven-badges.herokuapp.com/maven-central/io.github.raamcosta.compose-destinations/core)\"\u003e\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003eCompose 1.4 (1.4.x)\u003c/td\u003e\u003ctd\u003e\u003cimg alt=\"Maven Central\" src=\"https://img.shields.io/maven-metadata/v?versionPrefix=1.8\u0026color=blue\u0026metadataUrl=https://s01.oss.sonatype.org/service/local/repo_groups/public/content/io/github/raamcosta/compose-destinations/core/maven-metadata.xml\u0026style=for-the-badge)](https://maven-badges.herokuapp.com/maven-central/io.github.raamcosta.compose-destinations/core)\"\u003e\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003eCompose 1.5 (1.5.x)\u003c/td\u003e\u003ctd\u003e\u003cimg alt=\"Maven Central\" src=\"https://img.shields.io/maven-metadata/v?versionPrefix=1.9\u0026color=blue\u0026metadataUrl=https://s01.oss.sonatype.org/service/local/repo_groups/public/content/io/github/raamcosta/compose-destinations/core/maven-metadata.xml\u0026style=for-the-badge)](https://maven-badges.herokuapp.com/maven-central/io.github.raamcosta.compose-destinations/core)\"\u003e\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003eCompose 1.6 (1.6.x)\u003c/td\u003e\n    \u003ctd\u003e\n        \u003cimg alt=\"Maven Central\" src=\"https://img.shields.io/maven-metadata/v?versionPrefix=1.10\u0026color=blue\u0026metadataUrl=https://s01.oss.sonatype.org/service/local/repo_groups/public/content/io/github/raamcosta/compose-destinations/core/maven-metadata.xml\u0026style=for-the-badge)](https://maven-badges.herokuapp.com/maven-central/io.github.raamcosta.compose-destinations/core)\"\u003e\n        OR\n        \u003cimg alt=\"Maven Central\" src=\"https://img.shields.io/maven-metadata/v?versionPrefix=2.0\u0026color=blue\u0026metadataUrl=https://s01.oss.sonatype.org/service/local/repo_groups/public/content/io/github/raamcosta/compose-destinations/core/maven-metadata.xml\u0026style=for-the-badge)](https://maven-badges.herokuapp.com/maven-central/io.github.raamcosta.compose-destinations/core)\"\u003e\n    \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003eCompose 1.7 (1.7.x)\u003c/td\u003e\n    \u003ctd\u003e\n        \u003cimg alt=\"Maven Central\" src=\"https://img.shields.io/maven-metadata/v?versionPrefix=1.11\u0026color=blue\u0026metadataUrl=https://s01.oss.sonatype.org/service/local/repo_groups/public/content/io/github/raamcosta/compose-destinations/core/maven-metadata.xml\u0026style=for-the-badge)](https://maven-badges.herokuapp.com/maven-central/io.github.raamcosta.compose-destinations/core)\"\u003e\n        OR\n        \u003cimg alt=\"Maven Central\" src=\"https://img.shields.io/maven-metadata/v?versionPrefix=2.1\u0026color=blue\u0026metadataUrl=https://s01.oss.sonatype.org/service/local/repo_groups/public/content/io/github/raamcosta/compose-destinations/core/maven-metadata.xml\u0026style=for-the-badge)](https://maven-badges.herokuapp.com/maven-central/io.github.raamcosta.compose-destinations/core)\"\u003e\n    \u003c/td\u003e\n \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003e [!WARNING]  \n\u003e If you choose a version that uses a higher version of Compose than the one you're setting for your app, gradle will upgrade your Compose version via transitive dependency.\n\n\u003cdetails open\u003e\n  \u003csummary\u003egroovy - build.gradle(:module-name)\u003c/summary\u003e\n\n```gradle\nimplementation 'io.github.raamcosta.compose-destinations:core:\u003cversion\u003e'\nksp 'io.github.raamcosta.compose-destinations:ksp:\u003cversion\u003e'\n\n// V2 only: for bottom sheet destination support, also add\nimplementation 'io.github.raamcosta.compose-destinations:bottom-sheet:\u003cversion\u003e'\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003ekotlin - build.gradle.kts(:module-name)\u003c/summary\u003e  \n\n```gradle\nimplementation(\"io.github.raamcosta.compose-destinations:core:\u003cversion\u003e\")\nksp(\"io.github.raamcosta.compose-destinations:ksp:\u003cversion\u003e\")\n\n// V2 only: for bottom sheet destination support, also add\nimplementation(\"io.github.raamcosta.compose-destinations:bottom-sheet:\u003cversion\u003e\")\n```\n\u003c/details\u003e\n\n\u003e [!NOTE]  \n\u003e If you want to use Compose Destinations in a **Wear OS** app, replace above core dependency with: \u003c/br\u003e\n`implementation 'io.github.raamcosta.compose-destinations:wear-core:\u003cversion\u003e'` \u003c/br\u003e\n\u003e this will use [Wear Compose Navigation](https://developer.android.com/training/wearables/compose/navigation) internally. \u003c/br\u003e\n\u003e Read more about the next steps to configure these features [here](https://composedestinations.rafaelcosta.xyz/wear-os)\n\n# ⚠️ WARNING - `1.11.3-alpha` / `2.1.0-beta02` and above (Compose 1.7)\nOR if you got this error `kotlinx.serialization.SerializationException: Serializer for class 'DirectionImpl' is not found.`\n\n\n## - **DO NOT call `NavController.navigate` function** anywhere\nWith the introduction of type safe APIs on the official library, our `NavController` extension functions that received `Direction` are now shadowed by new member functions on `NavController`.  \nThis means that the official member function would be called instead of our extension functions, and so we removed those extension functions.  \nInstead, always make sure to use `DestinationsNavigator`. You can get one of such navigators by:\n\n- If inside a specific screen:\n   - Simply receive a `DestinationsNavigator` instead of `NavController` in your annotated screens.\n- If navigating on top level (such as around `DestinationsNavHost`, bottom nav bar, etc)\n   - `navController.rememberDestinationsNavigator()` if in a Composable\n   - `navController.toDestinationsNavigator()` if not in a Composable\n\nRead more about these changes [here](https://github.com/raamcosta/compose-destinations/releases/tag/2.1.0-beta02).\n\n## - **DO NOT depend on jetpack compose navigation directly**\nCompose Destinations provides the correct version transitively.  \nSo, if you have dependency on `androidx.navigation:navigation-compose`, please remove it! This has always been true, but more important now.\n\n## Community 💬\n\nPlease join the community at Kotlin slack channel: [#compose-destinations](https://kotlinlang.slack.com/archives/C06CS4UCQ10)  \nAsk questions, suggest improvements, or anything else related to the library.\n\n\n**If you like the library, consider starring and sharing it with your colleagues.**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraamcosta%2Fcompose-destinations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraamcosta%2Fcompose-destinations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraamcosta%2Fcompose-destinations/lists"}