Redirect before hydration end lead to hydration mismatch in prerendered pages. [ vike-vue ] #2221
-
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? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
See #1916. |
Beta Was this translation helpful? Give feedback.
See #1916.