How to deep link to nested navigators in React Navigation?

Viewed 511

My navigation structure is as follows:

const App = () => {
  const prefix = 'test://';
  return <AppNavigator uriPrefix={prefix} />;
};

const AppNavigator = createSwitchNavigator({
  splash: SplashScreen,
  auth: AuthStack,
  main: HomeStack,
});

const AuthStack = createStackNavigator({
  landing: LandingScreen,
  login: {
    screen: LoginScreen,
    path: 'page/login',
  },
  register: {
    screen: RegisterScreen,
    path: 'page/signup',
  },
});

const HomeStack = createStackNavigator({
  home: HomeScreen,
  details: {
    screen: DetailsScreen,
    path: 'details/:assetId',
  },
  upsell: {
    screen: UpsellScreen,
    path: 'page/upsell',
  },
});

My deep linking URI are:

test://page/login
test://page/signup
test://details/12345
test://page/upsell

On linking to any one of these URIs, I am always taken to the SplashScreen which is the first screen of my app. How do I link to nested navigators properly and link to the correct screen?

1 Answers
Related