Skip to content

How to have a layer between Router and Routes #10599

Closed Answered by brophdawg11
sazzer asked this question in Q&A
Discussion options

You must be logged in to vote

However, to minimise flickering, I don't want to render the routes until this has succeeded - it involves making an XHR call for an access token, so will take an amount of time.

This is exactly what the new Data Router paradigms aim to help with by completely decoupling data fetching from rendering. So what you really want (when using RouterProvider) is to do your auth checks in your loader and redirect there which (1) can be async and (2) happens completely before any rendering happens.

Otherwise, yes the solution would be is to move the stuff that used to live between BrowserRouter + Routes into a root layout route. But moving your data fetch8ing to loaders/actions should provide a mu…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sazzer
Comment options

Answer selected by sazzer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants