Vue Routing Issue: onData executes after page render #2926
Unanswered
jemmyk
asked this question in
Discussion
Replies: 1 comment 5 replies
-
|
What is it you're trying to achieve? |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Summary
Hi Rom:
When using Vike with Vue Router integration, the
+onData.tshook executes after the page component (Home.vue) is rendered.With Vike’s built-in router, the order is correct:
1 +onData.ts
2 Home.vue
But with Vue Router, the execution order becomes:
2 Home.vue <-- incorrect
1 +onData.ts <-- runs too late
This causes the page to render before data and store initialization are ready.
Expected Behavior
+onData.tsshould run before the page renders, just like it does with Vike's built-in router.Steps to Reproduce
The code modification described below has been published: https://github.com/jemmyk/vike-vue-router
Start from Vike's minimal example
Integrate Vue Router following Vike docs
Add console logs in:
pages/+onData.tspages/+Home.vueandpages/+About.vueNavigate client-side to the page
Observed order:
+Home.vue ❌
+onData.ts ❌
Expected:
+onData.ts ✔
+Home.vue ✔
Request
Is this intended?
If not, could Vike ensure
onDataruns before rendering when using Vue Router as well?Alternatively, is there anything we can do to work around this issue for now?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions