{"id":13822053,"url":"https://github.com/levinzonr/compose-safe-routing","last_synced_at":"2026-01-23T15:14:27.233Z","repository":{"id":38411884,"uuid":"372225040","full_name":"levinzonr/compose-safe-routing","owner":"levinzonr","description":"A library that enables Safe Navigation for your Composable destinations when using Jetpack Compose Navigation","archived":false,"fork":false,"pushed_at":"2023-09-19T09:40:25.000Z","size":3421,"stargazers_count":57,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-04T08:07:35.440Z","etag":null,"topics":["android","compose","jetpack","jetpack-compose","jetpackcompose","kotlin","navigation"],"latest_commit_sha":null,"homepage":"https://levinzonr.github.io/compose-safe-routing/","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/levinzonr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-05-30T13:45:04.000Z","updated_at":"2024-07-16T16:36:56.000Z","dependencies_parsed_at":"2024-01-15T15:46:36.949Z","dependency_job_id":"2b2632fd-d7c5-4cae-99e5-41e8b8d1664c","html_url":"https://github.com/levinzonr/compose-safe-routing","commit_stats":null,"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levinzonr%2Fcompose-safe-routing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levinzonr%2Fcompose-safe-routing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levinzonr%2Fcompose-safe-routing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levinzonr%2Fcompose-safe-routing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/levinzonr","download_url":"https://codeload.github.com/levinzonr/compose-safe-routing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225436473,"owners_count":17474149,"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","compose","jetpack","jetpack-compose","jetpackcompose","kotlin","navigation"],"created_at":"2024-08-04T08:01:40.307Z","updated_at":"2026-01-23T15:14:27.173Z","avatar_url":"https://github.com/levinzonr.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"[![](https://jitpack.io/v/levinzonr/compose-safe-routing.svg)](https://jitpack.io/#levinzonr/compose-safe-routing)\n\n[Medium Blogpost](https://levinzon-roman.medium.com/safe-easy-navigation-with-jetpack-compose-fdd5e0694930)\n\n[Monstar Blogpost](https://engineering.monstar-lab.com/2021/08/30/Safe-Navigation-With-Jetpack-Compose)\n\n![logo](docs/assets/logo.svg)\n\n\n\u003ch1 align=\"center\"\u003e \n   \u003ca href=\"https://levinzonr.github.io/compose-safe-routing/\"\u003eCompose SafeRoute\u003c/a\u003e\n\u003c/h1\u003e\n\nA small code generating library, inspired by SafeArgs for Android, that generates boilerplate code for defining your Navigation Graphs in Jetpack Compose in a type safe way.\n\n## Release Notes\n - [Version 2.5.0](RELEASE_NOTES.md/#250-release-notes-beta)\n - [Version 2.4.0](RELEASE_NOTES.md/#240-release-notes)\n - [Version 2.3.0](RELEASE_NOTES.md/#230-release-notes)\n - [Version 2.2.0](RELEASE_NOTES.md/#220-release-notes)\n - [Version 2.1.0](RELEASE_NOTES.md/#210-release-notes)\n - [Version 2.0.0](RELEASE_NOTES.md/#200-release-notes)\n\n## Features\n\n - Removes code duplication when describing your routes and its arguments through out the application\n - Helper functions to declare your Routes using `RouteSpec` interface \n - Support for Accompanist Animation/Material libraries \n - Helper functions that will allow to obtain passed arguments easily, both in your Composables and ViewModel using `CompositionLocal` and `SavedStateHandle` respectivly\n - Safety during navigation: The arguments you declared are always passed and obtained in a type-safe way\n - Mandatory \u0026 Optional parameters\n\n## Setup\n\nin your project level `build.gradle`\n```gradle\nallprojects {\n\trepositories {\n\t\t...\n\t\tmaven { url 'https://jitpack.io' }\n\t}\t\n}\n```\nAnd then in you app level `build.gradle`\n\n```kotlin\ndependencies { \n  // add either KAPT or KSP processor\n  ksp(\"com.github.levinzonr.compose-safe-routing:processor-ksp:2.5.0\")\n  kapt(\"com.github.levinzonr.compose-safe-routing:processor-kapt:2.5.0\")\n\n  implementation(\"com.github.levinzonr.compose-safe-routing:core:2.5.0\")\n  // or in case you are using animation/material routes from accompanist\n  implementation(\"com.github.levinzonr.compose-safe-routing:accompanist-navigation:2.5.0\")\n  \n}\n```\n\n\nIf you are using `KSP`, make sure you are also added KSP build folder\n\n```groovy\napplicationVariants.all { variant -\u003e\n    kotlin.sourceSets {\n        getByName(variant.name) {\n            kotlin.srcDir(\"build/generated/ksp/${variant.name}/kotlin\")\n        }\n    }\n}\n```\n\n## Basic Usage\n\nAt the core of the `SafeRoute` there is a `@Route` annotation. This annotation is used to describe your composable destination. Here is the basic setup for the Profile Screen\n\n```kotlin\n@Route(name = \"profile\")\n@Composable\nfun ProfileScreen() {\n    /** your screen */\n}\n```\n\nNext you might want to add some arguments to your route. This is done using `@RouteArg` annotation. It takes a name and the type of the param. Here you can also specify whether or not the argument is optional. This will determine how argument will be attached to the path and if default value should be used. Note that due to Annotations  limitations the default value is passed as `String` and then casted to the type specifed.\n\n```kotlin\n@Composable\n@Route(\"details\", args = [\n    RouteArg(\"id\", String::class, isOptional = false),\n    RouteArg(\"number\", Int::class, isOptional = true, defaultValue = \"1\"),\n]) \nfun DetailsScreen() {\n  /** sweet composable code ** /\n}\n```\n\nAfter you build the project, `SafeRoute` will generate multiple files based on the `@Route` annotations. These files now fully describe your Routes  and can be used  to describe you navigation graph easier and to navigate from one Route to another.\n\n```kotlin\nNavHost(startDestination = Routes.Profile.route) {\n  composable(ProfieRoute) { \n  \n     ProfileScreen(onShowDetails = {\n       // navController extension used to navigate\n       navController.navigateTo(DetailsRoute(id = \"hello\"))\n     })\n  }\n  \n   composable(DetailsRoute) {\n      // get the arguments\n      val args = LocalDetailsRouteArgs.current\n      DetailsScreen(args)\n   }\n  \n\n}\n```\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flevinzonr%2Fcompose-safe-routing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flevinzonr%2Fcompose-safe-routing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flevinzonr%2Fcompose-safe-routing/lists"}