Skip to content

Commit 3223983

Browse files
david-mears-2posva
andauthored
docs: Nuxt 2 --> 3 (#2766)
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> Co-authored-by: Eduardo San Martin Morote <posva13@gmail.com>
1 parent 67d3109 commit 3223983

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/docs/ssr/nuxt.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,18 @@ await useAsyncData('user', () => store.fetchUser().then(() => true))
6464

6565
::: tip
6666

67-
If you want to use a store outside of `setup()`, remember to pass the `pinia` object to `useStore()`. We added it to [the context](https://nuxtjs.org/docs/2.x/internals-glossary/context) so you have access to it in `asyncData()` and `fetch()`:
67+
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](https://pinia.vuejs.org/core-concepts/outside-component-usage.html#SSR-Apps). Retrieving the `pinia` instance might vary.
6868

69-
```js
69+
```ts
7070
import { useStore } from '~/stores/myStore'
7171

72-
export default {
73-
asyncData({ $pinia }) {
74-
const store = useStore($pinia)
75-
},
76-
}
72+
// this line is usually inside a function that is able to retrieve
73+
// the pinia instance
74+
const store = useStore(pinia)
7775
```
7876

77+
Fortunately, most of the time you **don't need to go through this hassle**.
78+
7979
:::
8080

8181
## Auto imports

0 commit comments

Comments
 (0)