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
@@ -87,7 +87,7 @@ By default `@pinia/nuxt` exposes a few auto imports:
87
87
-`storeToRefs()` when you need to extract individual refs from a store
88
88
-`acceptHMRUpdate()` for [hot module replacement](../cookbook/hot-module-replacement.md)
89
89
90
-
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:
90
+
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.
104
+
105
+
#### Merging Pinia Options Across Layers
106
+
107
+
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.
108
+
109
+
#### Example: Defining Stores in a Custom Layer
110
+
111
+
To define store directories for a specific layer, use the following approach:
-`currentDir` represents the directory of the current layer.
130
+
-`storesDirs` is set to point to the `stores` folder relative to the current layer's directory.
131
+
103
132
Note the folders are relative to the root of your project. If you change the `srcDir` option, you need to adapt the paths accordingly.
104
133
134
+
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).
135
+
105
136
## Nuxt 2 without bridge
106
137
107
138
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