2

I would like to know best practices implementing deep linking in react native/react navigation, naming conventions for schema, support of multiple deep links etc.

Cristian Flórez
  • 2,277
  • 5
  • 29
  • 51

1 Answers1

2

You can pass config as props in NavigationContainer and register multiple screens and configure links for the same. I would recommend to follow official documentation https://reactnavigation.org/docs/deep-linking/ for setup and https://reactnavigation.org/docs/configuring-linksfor configuring deep links.

Few scenarios to test for: i) app is in foreground ii) app is in background iii) app is in killed state and if you have authenticated screens then 3 more scenarios if user is in logged in state or not.

getInitialUrl() is helpful functions to know if app got launched by deep link url or not, because there can be scenarios where user isn't in logged-in state and app got launched using deep link etc. etc.

const link = useLinkTo() and link('yourDeepLink') function will help in passing the deep link as it as argument and it will be get internally parsed by react-native-navigation to work like .navigate() method. this would be helpful in case app got launched by deep link and user wasn't logged-in but you want to keep the deep link stored somewhere till user logs-in and then you want to land user on the configured deep link screen.

If you go one step ahead and configure universal links for iOS, you have to add support for associated domains and add apple-app-site-association file in .well-known directory of the domain you want to configure which kinda verifies that this domain is owned by this app. In android you can setup applinks and will have to place assetlinks.json file for the same reason as in ios. For your help https://developer.android.com/training/app-links

Sagar
  • 21
  • 2