Documentation Index
Fetch the complete documentation index at: https://mintlify.com/danielitoCode/compose_svelted/llms.txt
Use this file to discover all available pages before exploring further.
NavController is the single source of truth for navigation state in a Compose Svelted application. It holds an array of NavBackStackEntry objects inside a Svelte writable store. Every call to navigate() or popBackStack() updates that store, which causes the NavHost subscribed to it to re-render the appropriate screen automatically.
You will almost never instantiate NavController directly. The rememberNavController factory function is the recommended way to create one and is what all examples in this documentation use.
Types
Route
A route is a plain object with a single path string. It carries no behavior — it exists purely as a typed identifier that connects a controller call to a host registration.
routes.ts
NavBackStackEntry
Each entry in the backstack is a NavBackStackEntry. It records which route is active and carries any arguments that were passed when navigating to it.
args field is typed generically, so you can pass any serializable payload — a record with an id, a filter object, or nothing at all.
rememberNavController
The preferred way to create a NavController. Accepts the path of the start destination and returns a fully initialised controller.
<script> block, store it in Svelte context, or pass it as a prop — it is just an object.
NavController class
Constructor
{ route: startDestination }. The underlying writable store is created once and never replaced, so all subscribers always reference the same store identity.
navigate(route, args?)
NavBackStackEntry onto the top of the backstack. NavHost reacts immediately and renders the component registered for route.
Pass route paths via the
path property of your route constants (e.g. Details.path) rather than bare string literals. This keeps navigation calls refactor-safe and removes the risk of typos.popBackStack()
_getStackStore()
writable store. This method is used internally by NavHost and is prefixed with an underscore to signal that it is not part of the public API. Avoid calling it in application code.
Reading arguments in a screen
When you navigate with arguments, thenavBackStackEntry prop received by the target screen contains them under the args key. Destructure with a nullish fallback to handle the case where the screen is the start destination and no args were provided.
DetailsScreen.svelte
Complete example
The snippet below shows a self-contained navigation wrapper: routes are imported, a controller is created, and screens are wired up throughNavHost.
MainNavigationWrapper.svelte