Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use hash '#' in the URL with @react-navigation

I am working with react native web, where @react-navigation is used for navigation. I am using linking so that users can navigate using the URL.

my linking configuration looks like

const linking = {
  prefixes: [],
  config: {
    screens: {
      Home: '',
      Profile: 'profile',
      Settings: 'settings',
      NotFound: '*',
    },
  },
};

The problem is I would like to pass a parameter using # in the URL. For an example, localhost:19006/profile#address or localhost:19006/profile#about But when I try the above URL, react-navigation automatically removes #address / #about from the URL.

I went through https://reactnavigation.org/docs/configuring-links/

I can pass the parameter like localhost:19006/profile?sec=address easily, But I want to use # in the URL.

Is there any way to use # in the URL?

Note I am using the following libraries

"@react-navigation/native": "^6.0.10",
"@react-navigation/stack": "^6.2.1",
"react-native": "0.67.3",
"react-native-web": "^0.17.7",
like image 644
Shaon Debnath Avatar asked Oct 19 '25 10:10

Shaon Debnath


1 Answers

you need to import Linking from the react native.

import {Linking} from 'react-native

and whenever you need to open a URL with a click event you can code below.

Linking.openURL( "Your Link");

Might be it helpful to you.

like image 98
Ankit Vora Avatar answered Oct 21 '25 09:10

Ankit Vora



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!