@nuxt/docs-nightly 4.3.0-29481175.992d2a5d → 4.3.0-29481280.f3d5bc5f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -135,10 +135,6 @@ As stated above, `runtimeConfig` and `app.config` are both used to expose variab
135
135
 
136
136
  | Feature | `runtimeConfig` | `app.config` |
137
137
  |---------------------------|-----------------|--------------|
138
- | Client Side | Hydrated | Bundled |
139
- | Environment Variables | ✅ Yes | ❌ No |
140
- | Reactive | ✅ Yes | ✅ Yes |
141
- | Types support | ✅ Partial | ✅ Yes |
142
138
  | Client-side | Hydrated | Bundled |
143
139
  | Environment variables | ✅ Yes | ❌ No |
144
140
  | Reactive | ✅ Yes | ✅ Yes |
@@ -18,7 +18,7 @@ You don't need to add those local modules to your [`nuxt.config.ts`](/docs/4.x/d
18
18
  ```ts twoslash [modules/hello/index.ts]
19
19
  // `nuxt/kit` is a helper subpath import you can use when defining local modules
20
20
  // that means you do not need to add `@nuxt/kit` to your project's dependencies
21
- import { addServerHandler, createResolver, defineNuxtModule } from 'nuxt/kit'
21
+ import { addServerHandler, createResolver, defineNuxtModule, addComponentsDir } from 'nuxt/kit'
22
22
 
23
23
  export default defineNuxtModule({
24
24
  meta: {
@@ -32,6 +32,12 @@ export default defineNuxtModule({
32
32
  route: '/api/hello',
33
33
  handler: resolver.resolve('./runtime/api-route'),
34
34
  })
35
+
36
+ // Add components
37
+ addComponentsDir({
38
+ path: resolver.resolve('./runtime/app/components'),
39
+ pathPrefix: true // Prefix your exports to avoid conflicts with user code or other modules
40
+ })
35
41
  },
36
42
  })
37
43
  ```
@@ -46,6 +52,10 @@ export default defineEventHandler(() => {
46
52
 
47
53
  When starting Nuxt, the `hello` module will be registered and the `/api/hello` route will be available.
48
54
 
55
+ ::note
56
+ Note that all components, pages, composables and other files that would be normally placed in your `app/` directory need to be in `modules/your-module/runtime/app/`. This ensures they can be type-checked properly.
57
+ ::
58
+
49
59
  Modules are executed in the following sequence:
50
60
  - First, the modules defined in [`nuxt.config.ts`](/docs/4.x/api/nuxt-config#modules-1) are loaded.
51
61
  - Then, modules found in the `modules/` directory are executed, and they load in alphabetical order.
@@ -23,6 +23,9 @@ devtools.enabled=true
23
23
  # Add Nuxt modules
24
24
  modules[]=@nuxt/image
25
25
  modules[]=nuxt-security
26
+
27
+ # Module setups (automatically added by Nuxt)
28
+ setups.@nuxt/test-utils="3.23.0"
26
29
  ```
27
30
 
28
31
  If present, the properties in the `nuxt.config` file will overwrite the properties in `.nuxtrc` file.
@@ -100,7 +100,7 @@ export default defineNuxtModule({
100
100
  addComponent({
101
101
  name: 'MySuperComponent', // name of the component to be used in vue templates
102
102
  export: 'MySuperComponent', // (optional) if the component is a named (rather than default) export
103
- filePath: resolver.resolve('runtime/components/MySuperComponent.vue'),
103
+ filePath: resolver.resolve('runtime/app/components/MySuperComponent.vue'),
104
104
  })
105
105
 
106
106
  // From a library
@@ -123,7 +123,7 @@ export default defineNuxtModule({
123
123
  const resolver = createResolver(import.meta.url)
124
124
 
125
125
  addComponentsDir({
126
- path: resolver.resolve('runtime/components'),
126
+ path: resolver.resolve('runtime/app/components'),
127
127
  })
128
128
  },
129
129
  })
@@ -135,6 +135,10 @@ It is highly recommended to prefix your exports to avoid conflicts with user cod
135
135
  :read-more{to="/docs/4.x/guide/modules/best-practices#prefix-your-exports"}
136
136
  ::
137
137
 
138
+ ::note
139
+ Note that all components, pages, composables and other files that would be normally placed in your `app/` folder need to be in `runtime/app/`. This will mean they can be type checked properly.
140
+ ::
141
+
138
142
  ## Add Composables
139
143
 
140
144
  If your module should provide composables, you can use the `addImports` utility to add them as auto-imports for Nuxt to resolve.
@@ -149,7 +153,7 @@ export default defineNuxtModule({
149
153
  addImports({
150
154
  name: 'useComposable', // name of the composable to be used
151
155
  as: 'useMyComposable', // optional alias that will be available for the consuming apps
152
- from: resolver.resolve('runtime/composables/useComposable'), // path of composable
156
+ from: resolver.resolve('runtime/app/composables/useComposable'), // path of composable
153
157
  })
154
158
  },
155
159
  })
@@ -192,6 +196,10 @@ It is highly recommended to prefix your exports to avoid conflicts with user cod
192
196
  :read-more{to="/docs/4.x/guide/modules/best-practices#prefix-your-exports"}
193
197
  ::
194
198
 
199
+ ::note
200
+ Note that all components, pages, composables and other files that would be normally placed in your `app/` folder need to be in `runtime/app/`. This will mean they can be type checked properly.
201
+ ::
202
+
195
203
  ## Add Server Routes
196
204
 
197
205
  ```ts
@@ -222,6 +230,12 @@ export default defineNuxtModule({
222
230
  route: '/api/_my-module/hello/:name',
223
231
  handler: resolver.resolve('./runtime/server/api/hello/[name].get'),
224
232
  })
233
+
234
+ // Or using a catch all route
235
+ addServerHandler({
236
+ route: '/api/_my-module/files/**:path',
237
+ handler: resolver.resolve('./runtime/server/api/files/[...path].get'),
238
+ })
225
239
  },
226
240
  })
227
241
  ```
@@ -22,8 +22,8 @@ You can use `<NuxtLayout />` component to activate the `default` layout on `app.
22
22
 
23
23
  ## Props
24
24
 
25
- - `name`: Specify a layout name to be rendered, can be a string, reactive reference or a computed property. It **must** match the name of the corresponding layout file in the [`app/layouts/`](/docs/4.x/directory-structure/app/layouts) directory.
26
- - **type**: `string`
25
+ - `name`: Specify a layout name to be rendered, can be a string, reactive reference or a computed property. It **must** match the name of the corresponding layout file in the [`app/layouts/`](/docs/4.x/directory-structure/app/layouts) directory, or `false` to disable the layout.
26
+ - **type**: `string | false`
27
27
  - **default**: `default`
28
28
 
29
29
  ```vue [app/pages/index.vue]
@@ -136,6 +136,8 @@ Nuxt exposes the following properties through `ssrContext`:
136
136
 
137
137
  It is also possible to use more advanced types, such as `ref`, `reactive`, `shallowRef`, `shallowReactive` and `NuxtError`.
138
138
 
139
+ #### Custom Reducer/Reviver
140
+
139
141
  Since [Nuxt v3.4](https://nuxt.com/blog/v3-4#payload-enhancements), it is possible to define your own reducer/reviver for types that are not supported by Nuxt.
140
142
 
141
143
  :video-accordion{title="Watch a video from Alexander Lichter about serializing payloads, especially with regards to classes" videoId="8w6ffRBs8a4"}
@@ -46,3 +46,13 @@ export function useState<T> (key: string, init?: () => T | Ref<T>): Ref<T>
46
46
  - `key`: A unique key ensuring that data fetching is properly de-duplicated across requests. If you do not provide a key, then a key that is unique to the file and line number of the instance of [`useState`](/docs/4.x/api/composables/use-state) will be generated for you.
47
47
  - `init`: A function that provides initial value for the state when not initiated. This function can also return a `Ref`.
48
48
  - `T`: (typescript only) Specify the type of state
49
+
50
+ ## Troubleshooting
51
+
52
+ ### `Cannot stringify arbitrary non-POJOs`
53
+
54
+ This error occurs when you try to store a non-serializable payload with `useState`, such as class instances.
55
+
56
+ If you want to store class instances with `useState` that are not supported by Nuxt, you can use [`definePayloadPlugin`](/docs/4.x/api/composables/use-nuxt-app#custom-reducerreviver) to add a custom serializer and deserializer for your classes.
57
+
58
+ :read-more{to="/docs/4.x/api/composables/use-nuxt-app#payload"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/docs-nightly",
3
- "version": "4.3.0-29481175.992d2a5d",
3
+ "version": "4.3.0-29481280.f3d5bc5f",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",