Nested stores with SSR #1315
Answered
by
posva
m00nk
asked this question in
Help and Questions
Nested stores with SSR
#1315
-
I have several stores and some of them use some others. How do I create the stores inside the other stores for good working in SSR? I read I need to send the pinia object (root store object) into the store constructor when I create the stores for SSR like this: import {createPinia} from "pinia";
import MyStore from 'my-store';
app.use(pinia);
const myStore = MyStore(pinia); But do I need to do the same thing inside the store code to have an ability to use the other stores? Example: // file my-store.js
import {defineStore} from 'pinia';
import MyOtherStore from 'my-other-store';
export default defineStore('my-store', {
// ...
actions: {
someAction(){
const other = MyOtherStore(/* 1 */);
}
}
}
); Do I need to send the pinia object in (1) for SSR working right? If so, how can I get it? |
Beta Was this translation helpful? Give feedback.
Answered by
posva
May 22, 2022
Replies: 1 comment
-
No, you don’t need it |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
m00nk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No, you don’t need it