remove # from route
dinxsh opened this issue · 2 comments
To remove the "#" from the route in your React application, you can use the BrowserRouter
component provided by the React Router library.
Here's an example of how you can use it:
-
First, make sure that you have installed React Router in your project by running the following command:
npm install react-router-dom
-
Import the
BrowserRouter
component in your main app component:import { BrowserRouter } from 'react-router-dom';
-
Wrap your entire application inside the
BrowserRouter
component:import { BrowserRouter } from 'react-router-dom'; function App() { return ( <BrowserRouter> {/* your app content goes here */} </BrowserRouter> ); } export default App;
-
Use the
Link
component from React Router to create links to other pages in your application:import { Link } from 'react-router-dom'; function MyComponent() { return ( <Link to="/auth/default">Go to default page</Link> ); }
When the link is clicked, the URL in the browser address bar will change to
http://localhost:3000/auth/default
.
With these steps, you should now have a React application with clean, readable URLs without the "#" symbol.