Redirect before hydration end lead to hydration mismatch in prerendered pages. [ vike-vue ] #2221
Answered
by
brillout
AlexStep16
asked this question in
Discussion
|
Hello, I'm building an SSG+CSR application with vike-vue (no SSR). I need to fetch user data from an API and redirect unauthenticated users to the login page. I tried using +data.client.ts, but I'm getting a Hydration Mismatch because, as I understand, the data hook runs after hydration starts. onHydrationEnd() works, but I want to prevent content from showing before the auth check. guard() doesn't work client-side on prerendered pages. So maybe onBeforeRoute could be potential solution but it's global. What are the recommended approaches for implementing client-side authentication and redirect based on API data in SSG+CSR, avoiding Hydration Mismatch and ensuring the auth check happens before content is displayed? |
Answered by
brillout
Feb 25, 2025
Replies: 1 comment 7 replies
Answer selected by
AlexStep16
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See #1916.