100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Kotlin

Passing Arguments Between Screens

How to pass IDs, primitives, and complex data safely between destinations in Navigation Compose using route arguments and shared ViewModels.

NavigationIntermediate9 min readJul 8, 2026
Analogies

Passing Arguments Between Screens

Real apps rarely navigate to a bare screen — tapping a product in a list should open a detail screen for that specific product, which needs the product's ID (or the whole object) to know what to show. Navigation Compose supports this by embedding arguments directly in the route string, similar to how a web URL encodes a path parameter like /products/42, and by declaring the expected argument types on the destination so the framework can extract and validate them.

🏏

Cricket analogy: A stadium's ticket doesn't just say 'Enter Stadium' — it encodes the specific gate, block, and seat number, like /products/42, so the turnstile can validate and route the exact fan; similarly, tapping a specific player's profile needs their player ID embedded in the navigation route to show the right stats.

Defining a route with arguments

A parameterized route is declared with a placeholder in curly braces, e.g. "product/{productId}", and the destination lists a navArgument describing that placeholder's name and type. When navigating, the caller substitutes the real value into the route string; when the destination composes, it reads the value back out of the NavBackStackEntry's arguments bundle.

🏏

Cricket analogy: A scorecard route template like "match/{matchId}" is a blank template until you substitute in the actual fixture number when navigating from the schedule; the match screen then reads that matchId back out of its arguments to fetch the right scorecard.

kotlin
composable(
    route = "product/{productId}",
    arguments = listOf(navArgument("productId") { type = NavType.LongType })
) { backStackEntry ->
    val productId = backStackEntry.arguments?.getLong("productId") ?: 0L
    ProductDetailScreen(productId = productId)
}

// Navigating to it from a list:
@Composable
fun ProductListScreen(products: List<Product>, navController: NavController) {
    LazyColumn {
        items(products, key = { it.id }) { product ->
            ProductRow(
                product = product,
                onClick = { navController.navigate("product/${product.id}") }
            )
        }
    }
}

Optional arguments and query-style parameters

Optional data can be passed as query-style parameters, e.g. "search?query={query}", with navArgument marked nullable = true and given a defaultValue. This mirrors URL query parameters and is useful for filters or search terms that may or may not be present when a screen is opened.

🏏

Cricket analogy: A stadium's search screen accepts an optional filter like "search?team={team}" — you can browse all fixtures without specifying a team, or narrow results by adding one, mirroring an optional URL query parameter with a sensible default when none is given.

Never pass large or complex objects (like a full data class with nested lists) directly through a route string — routes are strings under the hood, and serializing/deserializing large objects through them is fragile and hurts performance. Pass only an ID and re-fetch or look up the full object in the destination's ViewModel.

Sharing data via a shared ViewModel instead

For data that doesn't fit neatly into a route (like a large object selected in one screen but needed in the next), a common alternative is scoping a ViewModel to a shared navigation graph so both screens can access the same instance. Navigation Compose supports this via hiltViewModel(backStackEntry) or navController.getBackStackEntry(route) combined with viewModel(viewModelStoreOwner = ...), letting a parent graph's ViewModel outlive individual screen navigations within that graph.

🏏

Cricket analogy: A team's full match analysis (large object) selected on a summary screen is too big to pass through the scoreboard route string, so both the summary and detail screens share the same 'innings ViewModel' scoped to the match graph — like sharing a scorer's full ledger rather than re-encoding it in a URL.

A useful mental model: route arguments are like function parameters passed by value (small, serializable, IDs or primitives), while a shared ViewModel is like a variable captured by reference in a closure shared by multiple screens — use IDs for the former and full objects for the latter.

Type-safe argument passing

Since Navigation Compose 2.8, routes can be defined as @Serializable data classes (e.g. data class ProductDetail(val productId: Long)), and navController.navigate(ProductDetail(productId = 42)) passes arguments with full compile-time type checking, removing the need to manually build route strings or declare navArgument lists by hand.

🏏

Cricket analogy: Instead of hand-writing a scorecard route string and hoping the fixture ID field name matches, declaring data class MatchDetail(val matchId: Long) lets navController.navigate(MatchDetail(matchId = 42)) catch a typo like passing a String at compile time, before the app ever ships.

  • Route arguments are declared with {placeholder} syntax and a matching navArgument specifying the type.
  • Destinations read arguments back from the NavBackStackEntry's arguments bundle (or via type-safe route objects).
  • Optional/query-style arguments use ?key={key} syntax with nullable = true and a defaultValue.
  • Pass only IDs or small primitives through routes; avoid serializing large objects into route strings.
  • A ViewModel scoped to a shared navigation graph is a better fit for sharing larger or complex data between screens.
  • Type-safe @Serializable route classes remove manual navArgument boilerplate and add compile-time safety.

Practice what you learned

Was this page helpful?

Topics covered

#Kotlin#AndroidWithJetpackComposeStudyNotes#MobileDevelopment#PassingArgumentsBetweenScreens#Passing#Arguments#Between#Screens#StudyNotes#SkillVeris

Frequently Asked Questions

21 categories · pick one to explore

Where can I get free study notes for programming and tech subjects?
SkillVeris offers completely free study notes covering programming and tech subjects, with no signup fees or paywalls. The notes are structured by course and topic, written for quick understanding, and enriched with the Learn Through Hobbies analogy method, so you can revise concepts through cricket, music, gaming, cooking and more.
Are SkillVeris study notes good for exam revision?
Yes, the study notes are designed for efficient revision: each topic answers its heading immediately, keeps explanations concise, and links to related glossary terms and cheat sheets. Students preparing for university exams or certification tests use them as quick revision notes because they distil concepts without the padding of full textbooks.
What subjects do the free study notes cover?
The study notes span the platform's main domains, including AI and machine learning, Python and programming, web development, DevOps, cloud, security and databases. Coverage mirrors the 37 live courses, so notes exist for the topics you are actually studying, and new note sets are added as courses launch.
How are SkillVeris study notes different from regular textbooks?
The notes are answer-first, concise and free, whereas textbooks are long and often expensive. Each section explains one concept directly, then reinforces it through selectable hobby analogies like cricket or cooking. Notes also cross-link to the glossary, blog and cheat sheets, letting you jump to related material instantly instead of flipping pages.
Can I use the developer study material without creating an account?
The study notes are free to access, and SkillVeris does not charge anything for its developer study material at any point. Browsing notes is straightforward from the Study Notes section, and if you want progress tracking, certificates and AI Mentor conversations tied to your learning, a free account unlocks those extras.
Do the study notes explain concepts with analogies?
Yes, this is a signature SkillVeris feature. Study notes use the Learn Through Hobbies method, explaining technical concepts through analogies from twelve domains including cricket, music, gaming, photography, travel, movies, fitness, chess, cooking, finance, business and sports. You can switch the analogy domain instantly to whichever hobby makes the concept click.
Are the revision notes suitable for last-minute exam preparation?
Yes, revision notes on SkillVeris work well for last-minute preparation because every section states the answer in its first sentences, so skimming is genuinely effective. Pair them with the relevant cheat sheet for formulas and syntax, and use the glossary for any unfamiliar term you meet while cramming.
Is there free study material for AI and machine learning?
Yes, SkillVeris provides free study notes across its AI and ML catalogue, covering Python for AI, deep learning frameworks like PyTorch and TensorFlow, Hugging Face Transformers, Large Language Models, RAG, AI agents and MLOps. All of it is free, making it a strong resource for Indian students and global learners alike.
Can beginners understand the study notes, or are they for experts?
Beginners can absolutely use them. The notes are written in plain language, define terms as they appear, and lean on hobby analogies to make abstract ideas concrete. Difficulty scales with the underlying course level, so beginner-course notes stay gentle while advanced-course notes go deeper, and the glossary supports you throughout.
How do study notes connect with SkillVeris courses?
Study notes are organised by course and topic, so they map directly to the structured courses and their 24–40-lesson curriculum. Many learners study a lesson first, then use the matching notes for revision before module assessments and the final exam, where 80 percent is required to pass and earn the certificate.
Are there study notes for Python specifically?
Yes, Python is well covered through notes tied to the Python-focused courses, including Python for AI and ML. Topics span fundamentals through applied machine learning usage. You can reinforce the notes with Python practice in Code Lab, which runs code in your browser with no installation required.
Do the study notes include code examples?
Yes, study notes include code examples wherever a concept is best shown in code, alongside explanations, key points and analogies. Reading a snippet in the notes and then reproducing it yourself in Code Lab is an effective loop, since Code Lab lets you run code in the browser across six languages.
How often is new study material added to SkillVeris?
Study material grows alongside the course catalogue. Whenever new courses join the platform's 37 live courses, matching study notes, glossary entries and cheat sheets are added so the resources stay in sync. Existing notes are also refined over time, so it is worth revisiting topics you studied earlier.
Can I use SkillVeris notes to prepare for technical interviews?
Yes, the notes make excellent interview revision because they compress each concept into direct, answer-first explanations, which mirrors how you should answer interview questions. Combine them with the SkillVeris interview questions feature, which includes readiness scoring, to test whether your revision has actually made you interview-ready.
Are the study notes mobile-friendly for studying on the go?
Yes, the study notes are built to load fast and read comfortably on mobile devices, so you can revise during a commute or between classes. Sections are short and answer-first, which suits small screens, and analogy switching works on mobile too, letting you study anywhere without carrying books.
What is the difference between study notes and cheat sheets?
Study notes explain concepts in depth with context, examples and analogies, making them ideal for learning and revision. Cheat sheets are compact quick-reference summaries of syntax, commands and key facts, ideal once you already understand a topic. Most learners study the notes first, then keep the cheat sheet handy while coding.
Do study notes help if I am stuck on a course lesson?
Yes, reading the matching study notes often clarifies a lesson because the same concept is explained from a different angle, frequently with a different analogy. If you are still stuck, ask the AI Mentor, which answers 24/7 at Quick, Detailed or Deep-dive depth until the idea genuinely makes sense.
Is there free study material for DevOps and cloud topics?
Yes, SkillVeris carries free study notes for DevOps and cloud topics as part of its coverage across 37 live courses. The material suits learners following the DevOps Engineer or Cloud Engineer paths, and it links to related glossary terms and cheat sheets so you can revise the whole toolchain in one place.
Can school or college students in India use these notes for projects?
Yes, students across India and worldwide use SkillVeris notes for coursework, projects and exam preparation, and everything is free, which matters for student budgets. The notes explain concepts clearly enough to cite in project reports, and Code Lab lets you prototype the project code directly in your browser.
How should I combine study notes with other SkillVeris resources?
A proven loop: learn from a course lesson, revise with the matching study notes, look up unfamiliar terms in the glossary, keep the cheat sheet open while practising in Code Lab, and quiz yourself with interview questions. The AI Mentor fills any remaining gaps 24/7, at whatever depth you need.

What Learners Say

Real journeys from the SkillVeris community — swipe for more.

SkillVeris taught me Python through Cricket. Now I’m building real projects and feeling confident!
Arjun S. · B.Tech Student
The best platform for hobby-based learning. Concepts finally stick.
Priya R. · Data Analyst
I went from zero coding to a portfolio of projects — all by learning through my love for gaming. Landed my first internship!
Kabir M. · CS Undergraduate
Trending Topics50 popular tags — tap to explore
Trending CoursesAll 37 free courses — tap to browse