You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: packages/docs/ssr/nuxt.md
+32-1
Original file line number
Diff line number
Diff line change
@@ -85,7 +85,7 @@ By default `@pinia/nuxt` exposes a few auto imports:
85
85
-`storeToRefs()` when you need to extract individual refs from a store
86
86
-`acceptHMRUpdate()` for [hot module replacement](../cookbook/hot-module-replacement.md)
87
87
88
-
It also automatically imports **all stores** defined within your `stores` folder. It doesn't lookup for nested stores though. You can customize this behavior by setting the `storesDirs` option:
88
+
It also automatically imports **all stores** defined within your `stores` folder in the main `srcDir` and all layers. It doesn't lookup nested stores though. You can customize this behavior by setting the `storesDirs` option:
**Note**: The folders are relative to the root of your project. If you change the `srcDir` option, you need to adjust the paths accordingly.
102
+
103
+
#### Merging Pinia Options Across Layers
104
+
105
+
Nuxt merges Pinia options from all layers, but defining the `storesDirs` option, such as `['./stores/**', './custom-folder/**']`, in your main `nuxt.config.ts` will only be resolved relative to the main `srcDir`. To ensure that your stores are correctly auto imported in layers, you need to define the `storesDirs` option for each layer individually.
106
+
107
+
#### Example: Defining Stores in a Custom Layer
108
+
109
+
To define store directories for a specific layer, use the following approach:
-`currentDir` represents the directory of the current layer.
128
+
-`storesDirs` is set to point to the `stores` folder relative to the current layer's directory.
129
+
101
130
Note the folders are relative to the root of your project. If you change the `srcDir` option, you need to adapt the paths accordingly.
102
131
132
+
For more detailed information on working with layers and relative paths in Nuxt, refer to the [Nuxt Documentation on Layers](https://nuxt.com/docs/guide/going-further/layers#relative-paths-and-aliases).
133
+
103
134
## Nuxt 2 without bridge
104
135
105
136
Pinia supports Nuxt 2 until `@pinia/nuxt` v0.2.1. Make sure to also install [`@nuxtjs/composition-api`](https://composition-api.nuxtjs.org/) alongside `pinia`:
0 commit comments