SSR, Nuxt, Pinia and Passing a Pinia Reference in .ts Files #3034
Unanswered
Romflz
asked this question in
Help and Questions
Replies: 0 comments
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.
-
Hi,
I'm a bit new to the SSR concepts and still trying to wrap my head around it.
I am using Pinia states in my middlewares for route guards, for example if authenticated, and in my plugins to populate state via API calls.
In the official docs https://pinia.vuejs.org/ssr/nuxt.html, there is a tip section:
"If you want to use a store outside of setup() or an injection aware context (e.g. Navigation guards, other stores, Nuxt Middlewares, etc), remember to pass the pinia instance to useStore(), for the reasons alluded to here. Retrieving the pinia instance might vary."
Is this for manual setup, or is this not needed for module based setup when using in Route middleware/Plugins? As many LLMS state if its in the Nuxt context, plugins and middlewares, there is no need. However I don't want to learn the wrong things an LLM wrote based on an incorrect statement. And it seems I cant find a lot of resources on this.
Additionally, when passing a new Pinia reference to the useStore, that reference comes from where? The only thing I am thinking is
const pinia = usePinia();
to pass it as a referenceApologies if this may be a duplicate of #2245 however even there, from 2023 its a bit confusing.
I would appreciate the help,
Thank you
Beta Was this translation helpful? Give feedback.
All reactions