Remove empty page when on "/" only

I'm not using refine default login but use other page to login to save the token and user info in localStorage and redirect to the app. However, if I navigate to "localhost:5173/", i want to make that route not exist and redirect to "localhost:5173/users" instead
2 Replies
kapa.ai
kapa.ai7mo ago
Hi @tads8799. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- In refine, you can customize the routing behavior according to your needs. To redirect from the root route (localhost:5173/) to a custom route (localhost:5173/users), you can use the react-router-dom's Navigate component. Here's a simplified example of how you can achieve this:
import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom";

function App() {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<Navigate to="/users" />} />
// Your other routes here...
</Routes>
</BrowserRouter>
);
}
import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom";

function App() {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<Navigate to="/users" />} />
// Your other routes here...
</Routes>
</BrowserRouter>
);
}
In this example, when users navigate to the root route (localhost:5173/), they will be immediately redirected to localhost:5173/users. Please note that this is a simplified example and you might need to adjust it according to your application's structure and needs. For more information about routing in refine, you can check the official documentation (https://refine.dev/docs). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai7mo ago
<@577213996344803338> kapa.ai is still learning and improving, please let us know how it did by reacting below