skip to content

Link, Redirect & Imperative Calls

Screens navigate with Link, the Redirect component or the router object's push, navigate, replace and dismiss calls. Interviewers ask which one adds history and how dismissTo behaves in a stack.

part ofExpo (React Native)overview, primer and where to startread it →
on this pageshow

explore

questions

5

In Expo Router 57, how do router.navigate, router.push and router.replace differ in what they add to a stack's history?

level: middleimportance: must knowfreq 55%

basics

~20 s

push always adds a stack entry; navigate adds one unless the target is the screen already on top with the same path params, which it updates in place; replace swaps the current entry, keeping history length unchanged.

open as a page

In Expo Router, how do router.back, dismiss, dismissTo and dismissAll differ when closing a multi-step refill flow inside a stack?

level: middleimportance: should knowfreq 35%

basics

~20 s

router.back goes back however the focused navigator defines it; dismiss(count) pops that many stack screens; dismissTo(href) pops until href is on top or replaces the current screen if it is absent; dismissAll returns to the nearest stack's first screen.

open as a page

In Expo Router, what does rendering <Redirect href> do, and how does it differ from calling router.replace directly in a screen?

level: middleimportance: should knowfreq 32%

basics

~20 s

Redirect renders nothing and calls router.replace(href) when its screen gains focus, so the target takes the current history entry; calling router.replace yourself needs the same timing, in a focus effect or handler, never during render.

open as a page

In an Expo Router pharmacy app, how would you return the user to the cart after sign-in, including when sign-in was opened by a cold-start deep link?

level: seniorimportance: should knowfreq 30%

basics

~20 s

Open sign-in with an href object carrying a returnTo param, validate that it is an internal path, and on success call router.dismissTo(returnTo), which pops back to the cart if it is in history and otherwise replaces sign-in with it.

open as a page