Navigation adds commands to the Commands panel that move your app around: open a screen that has no button leading to it yet, with the params you choose, go back, or reset the stack. It can also log every screen change in the Console.
Setting up Navigation in the SDK
Using navigation in the desktop app
Section titled “Using navigation in the desktop app”Running a navigation command
Section titled “Running a navigation command”The navigation commands are listed under Xerlock commands in the Commands panel. Select one, fill in its parameters and choose Run, as with any command.
| Command | What it does |
|---|---|
navigation.navigate |
Goes to the screen chosen in route, with the JSON object in params |
navigation.goBack |
Goes back in the focused navigator |
navigation.pop |
Pops count screens off the focused stack, 1 by default |
navigation.popToTop |
Pops the focused stack back to its first screen |
navigation.reset |
Resets navigation so the chosen screen is the only one, with optional params |
navigation.dispatch |
Dispatches a navigation action, such as { "type": "POP", "payload": { "count": 1 } } |
navigation.currentRoute |
Shows the focused route and the full navigation state |
Choosing a screen
Section titled “Choosing a screen”With Expo Router, route in navigation.navigate lists every file route by its href, such as
/suspects/[suspectId]. Groups like (tabs) are kept, index is dropped, and layouts aren’t listed.
Otherwise, and for navigation.reset in every app, route lists the route names of the navigators
that are mounted right now, such as suspects/[suspectId]. Nested navigators’ routes are listed
together, each name once, and Xerlock works out the nesting when the command runs. A name used by
more than one navigator goes to the first match, searching from the root navigator down.
The list updates whenever your app navigates. Type in the picker to filter it once it has 9 or more routes.
Filling in params
Section titled “Filling in params”Picking a route fills params with a starting point:
- A dynamic segment becomes an empty value:
/suspects/[suspectId]gives{ "suspectId": "" }and/evidence/[...path]gives{ "path": [] }. - Params your app has already opened that screen with are added, keeping the first value seen.
- With Expo Router, keys the screen reads with
useLocalSearchParamsoruseGlobalSearchParamsare added as"". Xerlock finds them in the screen’s source, and in the local files it imports, through Metro.
Picking another route replaces params only while it is empty or still the suggested text, so your own edits stay. params must be a JSON object.
Logging screen changes
Section titled “Logging screen changes”Turn on Navigation in the Console’s level filters to log each screen change as Navigated to …,
with its route, the path of navigator routes leading to it, and its params. The level is off by
default and listed only while the app has navigation set.
Limits and Troubleshooting
Section titled “Limits and Troubleshooting”- Without Expo Router, only mounted navigators are listed. A screen in a navigator that hasn’t
rendered yet, such as a lazy tab you haven’t opened, appears after your app first visits it.
Running a command for a name that isn’t mounted fails with
Route "…" isn't mounted right now. - With Expo Router, the
navigation.resetlist also includes Expo Router’s own routes, such as__root,+not-foundand_sitemap. - Search params are found by reading source, so they are a best guess. A key read with a computed
name, such as
params[name], isn’t found, and files innode_modulesaren’t read. Keys added while the app runs appear after a reload, or once the app opens the screen with them. navigation.goBackfails withNothing to go back toon the first screen.navigation.navigateandnavigation.resetare missing while the container hasn’t mounted. The other commands fail withNavigation isn't ready yetuntil it has.