Expo deep linking in React Native Web

1.1k Views Asked by At

Trying to make deep linking for React Native Web work. Browsed many articles and finally found a solution proposed for the exact problem faced in this link whch doesn't work for me.

Expo documentation says use

const prefix = Linking.makeUrl('/')

and set the prefix in the AppNavigator.

Wondering how can I point to my react native web app when use clicks a link. The problem is Linking.makeUrl('/') returns exp://localhost:19006/ on my laptop. As browser wouldn't recognize exp as scheme is unable to open my URL.

I tried setting the scheme to https in app.json but still Linking.makeUrl('/') returns the scheme as expo.

In my app when user clicks on static html page which I load in the app I want to route back to my app. As I am unable to get right scheme for React Native Web using Expo unable to proceed further.

Thank you.

Attaching the code provided in the link.

import React from 'react'
import { createSwitchNavigator } from '@react-navigation/core'
import { createBrowserApp } from "@react-navigation/web"
import { Linking } from 'expo'

const prefix = Linking.makeUrl('/')
const AppNavigator = createBrowserApp(createSwitchNavigator({
  Landing: {
    screen: LandingScreen,
    path: '/'
  },
  Login: {
    screen: LoginScreen,
    path: 'login'
}
}, {
  initialRouteName: 'Landing',
  backBehavior: 'history'
}))
export default () => <AppNavigator uriPrefix={prefix} />
1

There are 1 best solutions below

1
On

Try : const prefix = Linking.createURL('/');