Provide pageContext in prerender() and amend in onBeforeRender() #722
Unanswered
lutzissler
asked this question in
Help & Questions
Replies: 1 comment 21 replies
-
Have you tried to define one gloabl |
Beta Was this translation helpful? Give feedback.
21 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a Vue app with hundreds of pages generated from the same basic data. To speed up prerendering, I am fetching the data once and then use the
prerender()
hook to provide it in thepageContext
for all those pages, as the docs suggest.I am using Pinia though. With Pinia, I have to get the
initialStoreState
inonBeforeRender()
and include that inpageContext
as well, as shown in the example. Obviously the state is different for each of the dynamic routes, so I cannot provideinitialStoreState
from theprerender()
hook.Unfortunately, because I already return a
pageContext
in myprerender()
hook,onBeforeRender()
is not called during prerendering anymore. Ideally, it would still be called so I could amend thepageContext
already provided byprerender()
and put theinitialStoreState
there.Is there any way to achieve that?
Beta Was this translation helpful? Give feedback.
All reactions