ANDREA LAB / BLOG
Handling deep links during app startup with Expo Router
How to turn an external URL into an internal destination and coordinate navigation with session restoration in React Native.
Someone taps a link in an email to open a workshop listing. The app is closed. As React Native starts, the operating system delivers the URL and the app tries to restore the session. If the initial screen chooses where to navigate too early, the user can end up on the home screen without a clear way to reach the listing.
The problem breaks down into three decisions. The operating system determines which app receives the link. The app turns the URL into a known destination. Navigation waits for the information it needs to open that destination.
Separate delivery from interpretation
An Expo app can receive custom scheme URLs and HTTPS links associated with it on iOS or Android. HTTPS links allow you to share an address that also makes sense in a browser. Configure the domain association for each platform and verify it on an installed build.
Once the operating system delivers a URL, expo-linking lets the app read and parse it. In a custom scheme URL, the first segment can appear as the host. With HTTPS, the host identifies the domain and the path carries the resource segments. Both forms can map to the same internal destination before navigation decisions happen.
For example, these two fictional inputs can open the same workshop.
https://events.example/workshops/ceramics
studio://workshops/ceramics
Internal destination: /workshops/ceramics
The conversion should recognize specific origins and formats. Check the protocol, the host where relevant, the route shape, and accepted identifiers before constructing the destination. That gives you a place to handle an old link and offer a clear fallback for malformed input.
Coordinate startup with explicit states
Reading the initial URL with Linking.getInitialURL() is asynchronous. Startup logic needs to distinguish between a pending read, a completed read with no valid destination, and a read that found one. A single empty value for the first two cases lets the home screen redirect prematurely.
A coordinator can share the same read promise among screens involved in startup. Once resolution is ready, the component responsible for navigation applies one transition. Consume the initial destination once so it cannot reopen after the user presses Back or a screen mounts again.
A bounded wait helps when initial delivery is slow. Decide what the user sees when the deadline expires and how to handle a later arrival. A delayed result that abruptly replaces the screen the user is working in can be worse than offering a clear way to open the link again.
Carry the destination through sign-in
Suppose the workshop listing is public and the registration screen requires a session. The listing can open once the app navigator is ready. If the link points to registration, keep a validated internal destination while sign-in completes. After authentication, check that the destination is still applicable and fetch data using that session’s credentials.
Expo Router supports separating public and protected routes. For native link rewriting before navigation, it also offers +native-intent.tsx and redirectSystemPath. That stage is suited to normalizing the destination. Decisions that depend on the session belong where authentication state is available. Customizing links · Authentication in Expo Router.
Choose who controls each transition
If Expo Router already opens the screen specified by the URL, an effect that repeats that navigation when the initial screen mounts can create two history entries. One way to divide responsibility is to normalize the URL in one place and let the navigator resolve the route. If the flow saves an intent while the user signs in, the component that resumes it needs to distinguish it from navigation that already happened.
It also matters what happens if another link arrives before the first is consumed. In the workshop example, the product can let the user's latest explicit action replace the pending destination. If a registration is in progress, it can preserve the form and ask the user to finish or close it before opening another listing. Both policies can be expressed and tested independently of which React effect runs first.
Test startup and foreground behavior
Use the same link on a device with the app closed and with it in the foreground. Repeat with an active session, without a session, and with slow session restoration. Include a malformed link and one that points to a removed resource. Once the destination opens, press Back and check that the initial intent does not trigger again.
With Expo Router, the experience depends on both the final route and when the decision happens. A validated destination and a clear point of consumption allow links from email, the browser, and other apps to share the same navigation behavior.