Redirect on initial load; conflicts with hydration
Greetings. I am wondering about the implementation of a rather simple "pattern" that is common but somehow I alone seem to be struggling with.
I wish to redirect logged in users from the index page to /home (which is common on the web). What I am trying to do is to—in the middleware—poll the backend to see if I am logged in and
navigateTo("/home")
navigateTo("/home")
if true. The problem is that this breaks with SSR, since I would be redirecting during hydration.
Is my approach stupid? Is the redirect perhaps supposed to be initiated from the backend... somehow? Is it possible to somehow "await" hydration and redirect afterwards?