{"id":277816,"date":"2025-06-03T14:50:23","date_gmt":"2025-06-03T14:50:23","guid":{"rendered":"https:\/\/michigandigitalnews.com\/index.php\/2025\/06\/03\/android-developers-blog-announcing-jetpack-navigation-3\/"},"modified":"2025-06-25T17:08:12","modified_gmt":"2025-06-25T17:08:12","slug":"android-developers-blog-announcing-jetpack-navigation-3","status":"publish","type":"post","link":"https:\/\/michigandigitalnews.com\/index.php\/2025\/06\/03\/android-developers-blog-announcing-jetpack-navigation-3\/","title":{"rendered":"Android Developers Blog: Announcing Jetpack Navigation 3"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div>\n<div>\n<meta content=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEizVuum2Jg1s5Y5EQmfuXrjm8QqcqxdAUDveRe-CSS4ZGVeNG9VFEizeayzpolJ5oCPSfoNmkT3RdS3Z-g1-aXzDBWwJtjOzflCgt657KFitWQby_GcYa5PO4PBN_7IUmG4CC9BvOw8mFFIMPai_R9EoPIcWZkPDV0aAAs20amwT6Lr2oXi5Yfe-e7b1t0\/s1600\/announcing-jetpack-navigation-3-compose-google-io-2025.png\" name=\"twitter:image\"\/><br \/>\n<img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEizVuum2Jg1s5Y5EQmfuXrjm8QqcqxdAUDveRe-CSS4ZGVeNG9VFEizeayzpolJ5oCPSfoNmkT3RdS3Z-g1-aXzDBWwJtjOzflCgt657KFitWQby_GcYa5PO4PBN_7IUmG4CC9BvOw8mFFIMPai_R9EoPIcWZkPDV0aAAs20amwT6Lr2oXi5Yfe-e7b1t0\/s1600\/announcing-jetpack-navigation-3-compose-google-io-2025.png\" style=\"display: none;\"\/><\/p>\n<p><em>Posted by Don Turner &#8211; Developer Relations Engineer<\/em><\/p>\n<p><a href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEiAaXdjIziCSWC6AxDELcBes5wYDD03GByPFm8jipBg5cilU9-3w_50B5RhF1BXzHUY0HTmp-WEAeshuqLmBpdK9onZAys4S3Pv2izciuQxqlTL23YaOCpaGMoazKbXUCHr5TZcDadxWbDdUDAX_1GS_iN133wFnxH-Qal7icpfcZhKZ2aNy3FaJ0zIDds\/s1600\/new-in-jetpack-compose.png\"><img decoding=\"async\" border=\"0\" data-original-height=\"800\" data-original-width=\"100%\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEiAaXdjIziCSWC6AxDELcBes5wYDD03GByPFm8jipBg5cilU9-3w_50B5RhF1BXzHUY0HTmp-WEAeshuqLmBpdK9onZAys4S3Pv2izciuQxqlTL23YaOCpaGMoazKbXUCHr5TZcDadxWbDdUDAX_1GS_iN133wFnxH-Qal7icpfcZhKZ2aNy3FaJ0zIDds\/s1600\/new-in-jetpack-compose.png\"\/><\/a><\/p>\n<p>Navigating between screens in your app should be simple, shouldn&#8217;t it? However, building a robust, scalable, and delightful navigation experience can be a challenge. For years, the Jetpack Navigation library has been a key tool for developers, but as the Android UI landscape has evolved, particularly with the rise of Jetpack Compose, we recognized the need for a new approach.<\/p>\n<p>Today, we&#8217;re excited to introduce <b>Jetpack Navigation 3<\/b>, a new navigation library built from the ground up specifically for Compose. For brevity, we&#8217;ll just call it Nav3 from now on. This library embraces the <a href=\"https:\/\/developer.android.com\/develop\/ui\/compose\/mental-model\" target=\"_blank\" rel=\"noopener\">declarative programming model<\/a> and <a href=\"https:\/\/developer.android.com\/develop\/ui\/compose\/state\" target=\"_blank\" rel=\"noopener\">Compose state<\/a> as fundamental building blocks.<\/p>\n<h2><span style=\"font-size: x-large;\">Why a new navigation library?<\/span><\/h2>\n<p>The original Jetpack Navigation library (sometimes referred to as Nav2 as it&#8217;s on major version 2) was initially announced back in 2018, before AndroidX and before Compose. While it served its original goals well, we heard from you that it had several limitations when working with modern Compose patterns.<\/p>\n<p>One key limitation was that the back stack state could only be observed indirectly. This meant there could be two sources of truth, potentially leading to an inconsistent application state. Also, Nav2&#8217;s <span style=\"color: #0d904f; font-family: courier;\">NavHost<\/span> was designed to display only a single destination \u2013 the topmost one on the back stack \u2013 filling the available space. This made it difficult to implement adaptive layouts that display multiple panes of content simultaneously, such as a list-detail layout on large screens.<\/p>\n<p><image><\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" alt=\"illustration of single pane and two-pane layouts showing list and detail features\" border=\"0\" id=\"imgCaption\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEh-1rxgQm0Xe0H1TsZIg7R9XC_jKoDZp8XuC0WBCy7iFTZpxrXEmCaFPBhLJUlsjhyDJVYXD5gqRmyoJsJEufJtIEr5JqGDBdQ05-1ytf75MtNAuwX3x4lBzAEUByOgOzeXfqgx6wGROHdRclzdvCKUJQVxO7BO6MFNNk1_uizsv44UoTjlUTecHDptLbs\/s1600\/single-pane-to-multi-pane-layout-jetpack-navigation-3-compose-google-io.png\" width=\"100%\"\/><\/div>\n<p><imgcaption><center><em><b>Figure 1.<\/b> Changing from single pane to multi-pane layouts can create navigational challenges<\/em><\/center><\/imgcaption><\/image><\/p>\n<h2><span style=\"font-size: x-large;\">Founding principles<\/span><\/h2>\n<p>Nav3 is built upon principles designed to provide greater flexibility and developer control:<\/p>\n<ul>\n<ul>\n<li><b>You own the back stack:<\/b> You, the developer, not the library, own and control the back stack. It&#8217;s a simple list which is backed by Compose state. Specifically, Nav3 expects your back stack to be <span style=\"color: #0d904f; font-family: courier;\">SnapshotStateList<t\/><\/span> where <span style=\"color: #0d904f; font-family: courier;\">T<\/span> can be any type you choose. You can navigate by adding or removing items (<span style=\"color: #0d904f; font-family: courier;\">T<\/span>s), and state changes are observed and reflected by Nav3&#8217;s UI.<\/li>\n<\/ul>\n<ul>\n<li><b>Get out of your way:<\/b> We heard that you don&#8217;t like a navigation library to be a black box with inaccessible internal components and state. Nav3 is designed to be open and extensible, providing you with building blocks and helpful defaults. If you want custom navigation behavior you can <a href=\"https:\/\/developer.android.com\/develop\/ui\/compose\/layering\" target=\"_blank\" rel=\"noopener\">drop down to lower layers<\/a> and create your own components and customizations.<\/li>\n<\/ul>\n<ul>\n<li><b>Pick your building blocks:<\/b> Instead of embedding all behavior within the library, Nav3 offers smaller components that you can combine to create more complex functionality. We&#8217;ve also provided a &#8220;<a href=\"http:\/\/github.com\/android\/nav3-recipes\" target=\"_blank\" rel=\"noopener\">recipes book<\/a>&#8221; that shows how to combine components to solve common navigation challenges.<\/li>\n<\/ul>\n<\/ul>\n<p><\/p>\n<p><image><\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" alt=\"illustration of the Nav3 display observing changes to the developer-owned back stack\" border=\"0\" id=\"imgCaption\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEhA8RGixTxeZgkz1oQftv442euofSEXYiJ0tgRc-WcmQCXCLp0NhoTazDYbPXpjZkXqUlMXFrI5s2yoU0Cv8ZhHZpnY-rYfbKlW_TWzdCmk3pcdzTHjdFb-8FLTpK4K3Z8VEc_jqqZQ1oAbouUh-Zyk5oAfR20USvHs8bdZha_tmX6d5Kuo7Ydy8yNKyLg\/s1600\/nav3-display-observes-changes-developer-owned-back-stack.png\" width=\"100%\"\/><\/div>\n<p><imgcaption><center><em><b>Figure 2.<\/b> The Nav3 display observes changes to the developer-owned back stack.<\/em><\/center><\/imgcaption><\/image><\/p>\n<h2><span style=\"font-size: x-large;\">Key features<\/span><\/h2>\n<ul>\n<ul>\n<li><b>Adaptive layouts:<\/b> A <a href=\"https:\/\/developer.android.com\/guide\/navigation\/navigation-3\/custom-layouts\" target=\"_blank\" rel=\"noopener\">flexible layout API<\/a> (named <span style=\"color: #0d904f; font-family: courier;\">Scenes<\/span>) allows you to render multiple destinations in the same layout (for example, a list-detail layout on large screen devices). This makes it easy to switch between single and multi-pane layouts.<\/li>\n<\/ul>\n<ul>\n<li><b>Modularity:<\/b> The API design allows navigation code to be split across multiple modules. This improves build times and allows clear separation of responsibilities between feature modules.<\/li>\n<\/ul>\n<ul><image><\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" alt=\"moving image demonstrating custom animations and predictive back features on a mobile device\" border=\"0\" id=\"imgCaption\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEhw5KERXwQVYgw5cqqM86exFaib_HqfUs3SyCLCbZvSeNY5cV_ax67Wg_w-76fcG4MGBADm24rIfehu871ngLhMa_-EeHFYikcp9Ag2Q1JCNhmvEaz7YHsBz72B6pOZCHtAink0Qnqs7jK9dPp7zXueKECKQJ8SvJIm0tO9LD0OZYddsRI_mx7qieURDn8\/s1600\/jetpack-navigation-3-custom-animation-predictive-back-google-io.gif\" width=\"40%\"\/><\/div>\n<p><imgcaption><center><em><b>Figure 3.<\/b> Custom animations and predictive back are easy to implement, and easy to override for individual destinations. <\/em><\/center><\/imgcaption><\/image><\/p>\n<h2><span style=\"font-size: x-large;\">Basic code example<\/span><\/h2>\n<p>To give you an idea of how Nav3 works, here&#8217;s a short code sample.<\/p>\n<p><!--Kotlin--><\/p>\n<div style=\"background: rgb(248, 248, 248); border: 0px; overflow: auto; width: auto;\">\n<pre style=\"line-height: 125%; margin: 0px;\"><span style=\"color: #408080; font-style: italic;\">\/\/ Define the routes in your app and any arguments.<\/span>\ndata object Home\ndata <span style=\"color: green; font-weight: bold;\">class<\/span> <span style=\"color: blue;\">Product<\/span>(<span style=\"color: green; font-weight: bold;\">val<\/span> id: String)\n\n<span style=\"color: #408080; font-style: italic;\">\/\/ Create a back stack, specifying the route the app should start with.<\/span>\n<span style=\"color: green; font-weight: bold;\">val<\/span> backStack = remember { mutableStateListOf<any>(Home) }\n\n<span style=\"color: #408080; font-style: italic;\">\/\/ A NavDisplay displays your back stack. Whenever the back stack changes, the display updates.<\/span>\nNavDisplay(\n    backStack = backStack,\n\n    <span style=\"color: #408080; font-style: italic;\">\/\/ Specify what should happen when the user goes back<\/span>\n    onBack = { backStack.removeLastOrNull() },\n\n    <span style=\"color: #408080; font-style: italic;\">\/\/ An entry provider converts a route into a NavEntry which contains the content for that route.<\/span>\n    entryProvider = { route -&gt;\n        <span style=\"color: green; font-weight: bold;\">when<\/span> (route) {\n            <span style=\"color: green; font-weight: bold;\">is<\/span> Home -&gt; NavEntry(route) {\n                Column {\n                    Text(<span style=\"color: #ba2121;\">\"Welcome to Nav3\"<\/span>)\n                    Button(onClick = {\n                        <span style=\"color: #408080; font-style: italic;\">\/\/ To navigate to a new route, just add that route to the back stack<\/span>\n                        backStack.add(Product(<span style=\"color: #ba2121;\">\"123\"<\/span>))\n                    }) {\n                        Text(<span style=\"color: #ba2121;\">\"Click to navigate\"<\/span>)\n                    }\n                }\n            }\n            <span style=\"color: green; font-weight: bold;\">is<\/span> Product -&gt; NavEntry(route) {\n                Text(<span style=\"color: #ba2121;\">\"Product ${route.id} \"<\/span>)\n            }\n            <span style=\"color: green; font-weight: bold;\">else<\/span> -&gt; NavEntry(Unit) { Text(<span style=\"color: #ba2121;\">\"Unknown route: $route\"<\/span>) }\n        }\n    }\n)\n<\/any><\/pre>\n<\/div>\n<h2><span style=\"font-size: x-large;\">Get started and provide feedback<\/span><\/h2>\n<p>To get started, check out <a href=\"https:\/\/goo.gle\/nav3\" target=\"_blank\" rel=\"noopener\">the developer documentation<\/a>, plus the <a href=\"https:\/\/github.com\/android\/nav3-recipes\" target=\"_blank\" rel=\"noopener\">recipes repository<\/a> which provides examples for:<\/p>\n<ul>\n<ul>\n<li>common navigation UI, such as a navigation rail or bar<\/li>\n<li>conditional navigation, such as a login flow<\/li>\n<li>custom layouts using <span style=\"color: #0d904f; font-family: courier;\">Scenes<\/span><\/li>\n<\/ul>\n<\/ul>\n<p>We plan to provide code recipes, documentation and blogs for more complex use cases in future.<\/p>\n<p>Nav3 is currently in alpha, which means that the API is liable to change based on feedback. If you have any issues, or would like to provide feedback, please <a href=\"https:\/\/issuetracker.google.com\/issues\/new?component=1750212&amp;template=2102223\" target=\"_blank\" rel=\"noopener\">file an issue<\/a>.<\/p>\n<p>Nav3 offers a flexible and powerful foundation for building modern navigation in your Compose applications. We&#8217;re really excited to see what you build with it.<\/p>\n<p>Explore this announcement and all Google I\/O 2025 updates on <a href=\"https:\/\/io.google\/2025\/?utm_source=blogpost&amp;utm_medium=pr&amp;utm_campaign=event&amp;utm_content=\" target=\"_blank\" rel=\"noopener\">io.google<\/a> starting May 22.<\/p>\n<\/ul>\n<\/ul>\n<\/div>\n<hr\/>\n<\/div>\n<p>[ad_2]<br \/>\n<br \/><a href=\"http:\/\/android-developers.googleblog.com\/2025\/05\/announcing-jetpack-navigation-3-for-compose.html\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Posted by Don Turner &#8211; Developer Relations Engineer Navigating between screens in your app should be simple, shouldn&#8217;t it? However, building a robust, scalable,<\/p>\n","protected":false},"author":1,"featured_media":277817,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[146],"tags":[],"_links":{"self":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts\/277816"}],"collection":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/comments?post=277816"}],"version-history":[{"count":0,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts\/277816\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/media\/277817"}],"wp:attachment":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/media?parent=277816"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/categories?post=277816"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/tags?post=277816"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}