Two different routers? #11059
Replies: 1 comment 2 replies
-
Hey @thekaganugur! You are definitely right, the links you provided are focused more on very complex components being built on the react-router infrastructure within one browser router, i dont think this is what you need! Hopefully I can help though ~ Going off some assumptions here, but i think i understand what you are trying to do: Assumptions: Even though certain pages will only be accessed by an authenticated user, its still okay if they write to the URL. Here are a few tips on handling this: If you have access to the users authenticated session at the time of the web request you can 301 redirect the user to a different URL if they are unauthorized. Since your distribution is just a public javascript file (asuming your using webpack or something similar to bundle your javascript), I wrote this using older adding props to help get the point across, but ultimately its highly dependent on how you handle and process your authorized user! <Routes>
<Route path="" element={<Layout userLoggedIn={false} />}>
<Route path="login" element={<Login />} />
<Route path="refer" element={<Refer />} />
</Route>
<Route path="app" element={<Layout userLoggedIn={true} />}>
<Route path="dashboard" element={<Dashboard />} />
</Route>
</Routes> Ultimately I think the problem is based less on how you would setup |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have a case where I need a few public pages like:
/login
,login/otp
,/refer
and maybe a few more. These paths will be seen in the URL. They can be accessed via a link. For this partbrowserrouter
works perfectly.Other than everything will be behind the authentication wall. I want to hide the URL from the address bar on all of the things here and for these pages, there is no need to read the address bar too. These pages can be only accessed via in-app.
In summary
I need a few pages like
/login
,login/otp
,/refer
to read and write to the address barI need other pages to not read and write to the address bar. They can be accessed via only in-app navigation.
I'm not sure how to achieve this. This seems a bit different need than #10050 or #9601 and wasn't able to find a discussion that matches my needs.
Beta Was this translation helpful? Give feedback.
All reactions