Replies: 3 comments
-
I also have the same question |
Beta Was this translation helpful? Give feedback.
0 replies
-
@sealmu have you find any solution for that ? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Routes list can be dynamic, there is nothing wrong in this approach. If you want static routes to be protected you can use some general patterns.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How to implement role-based routing with createBrowserRouter?
I want the same routes(ex. "/", "/profile", "dashboard") depending on the user role logged in to be rendered with the different components(ex. ClientProfile, OwnerProfile, DeliveryProfile).
And when it's public, for no logged-in user I want only some routes to be enabled(ex. "/" - for MainPage).
I can create several distinguished routes with createBrowserRouter(ex. ClientRouter, OwnerRouter, etc.) and provide the right one based on the app state to "<RouterProvider router={appRouter}".
But it looks like a wrong approach and too cumbersome relative to the previous version of the dynamically rendered routes when it could be implemented easily by conditional rendering.
Beta Was this translation helpful? Give feedback.
All reactions