The currently logged in user should not be fetched client side, but server side. Also, this should only be done ONCE when the page is loaded / refreshed in order to reduce api requests. It is thus necessary to implement this on the highest level possible, optimally in _app.tsx.
Furthermore, based on the authentication status and requested URL, the user should be redirected without a flashing screen.
I.e., if she is not authenticated and tries to access /dashboard, the redirect should happen without even displaying the /dashbaord page for a millisecond.
The currently logged in user should not be fetched client side, but server side. Also, this should only be done ONCE when the page is loaded / refreshed in order to reduce api requests. It is thus necessary to implement this on the highest level possible, optimally in _app.tsx.
Furthermore, based on the authentication status and requested URL, the user should be redirected without a flashing screen. I.e., if she is not authenticated and tries to access /dashboard, the redirect should happen without even displaying the /dashbaord page for a millisecond.