Using stores inside different store actions and passing Pinia instance on SSR #2457
Unanswered
niksy
asked this question in
Help and Questions
Replies: 1 comment
-
I'm curious if something like this would work:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Let’s say I have following application code:
Component
app.vue
looks like this:Store
./page-store.js
looks like this:And explanation on some core parts is as following:
fetchData
is called on SSR to fetch initial data, and on each route change when that component gets activatedfetchData
since it’s just static method without any knowledge of Vue instanceawait
calls to prevent losing Pinia instance contextMy question is do we also need to pass Pinia instance to
useMainStore
call insideusePageStore
action when running inside SSR, or is that considered under definition "inside component" and it’s not necessary inside that context?Is Pinia already implicitly available for every page store instantiation if Pinia instance was passed before when instantiating parent store? I know that should work for non-SSR (client) context, but I’m not sure for SSR context.
For example, in the code example for shared actions call to
useUserStore
doesn’t have Pinia instance as argument, and the documentation mentions SSR apps, so my understanding is that it isn’t necessary to pass Pinia instance to any external store calls inside actions if it was already passed down to parent store which has that action defined.Beta Was this translation helpful? Give feedback.
All reactions