@nuxt/docs-nightly 4.3.0-29481970.f136022c → 4.3.0-29483992.8d4f9ba5

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.
@@ -156,10 +156,16 @@ export default defineNuxtConfig({
156
156
  '/admin': { appLayout: 'admin' },
157
157
  // Set layout for multiple routes
158
158
  '/dashboard/**': { appLayout: 'dashboard' },
159
+ // Disable layout for a route
160
+ '/landing': { appLayout: false },
159
161
  },
160
162
  })
161
163
  ```
162
164
 
165
+ ::tip
166
+ This is useful when you want to manage layouts centrally in your configuration rather than in each page file, or when you need to apply layouts to routes that don't have corresponding page components (such as catchall pages which might match many paths).
167
+ ::
168
+
163
169
  :link-example{to="/docs/4.x/examples/features/layouts"}
164
170
 
165
171
  ## Overriding a Layout on a Per-page Basis
@@ -41,6 +41,19 @@ export default defineNuxtConfig({
41
41
  Nuxt modules are now build-time-only, and the `buildModules` property used in Nuxt 2 is deprecated in favor of `modules`.
42
42
  ::
43
43
 
44
+ ## Disabling Modules
45
+
46
+ You can disable a module by setting its config key to `false` in your Nuxt config. This is particularly useful when you want to disable modules inherited from layers.
47
+
48
+ ```ts [nuxt.config.ts]
49
+ export default defineNuxtConfig({
50
+ // Disable `@nuxt/image` module
51
+ image: false,
52
+ })
53
+ ```
54
+
55
+ :read-more{to="/docs/4.x/guide/going-further/layers#disabling-modules-from-layers"}
56
+
44
57
  ## Create a Nuxt Module
45
58
 
46
59
  Everyone has the opportunity to develop modules and we cannot wait to see what you will build.
@@ -248,6 +248,21 @@ export default defineNuxtConfig({
248
248
  })
249
249
  ```
250
250
 
251
+ Payload extraction also works for routes using ISR (Incremental Static Regeneration) or SWR (Stale-While-Revalidate) caching strategies. This allows CDNs to cache payload files alongside HTML, improving client-side navigation performance for cached routes.
252
+
253
+ ```ts twoslash [nuxt.config.ts]
254
+ export default defineNuxtConfig({
255
+ experimental: {
256
+ payloadExtraction: true,
257
+ },
258
+ routeRules: {
259
+ // Payload files will be generated for these cached routes
260
+ '/products/**': { isr: 3600 },
261
+ '/blog/**': { swr: true },
262
+ },
263
+ })
264
+ ```
265
+
251
266
  ## clientFallback
252
267
 
253
268
  Enables the experimental [`<NuxtClientFallback>`](/docs/4.x/api/components/nuxt-client-fallback) component for rendering content on the client if there's an error in SSR.
@@ -249,6 +249,32 @@ export default defineNuxtConfig({
249
249
  })
250
250
  ```
251
251
 
252
+ ## Disabling Modules from Layers
253
+
254
+ When extending a layer, you might want to disable certain modules that it includes. You can do this by setting the module's config key to `false` in your Nuxt config.
255
+
256
+ ```ts [nuxt.config.ts]
257
+ export default defineNuxtConfig({
258
+ extends: ['./base-layer'],
259
+ // Disable modules from the layer by setting their config key to false
260
+ image: false, // Disables @nuxt/image
261
+ pinia: false, // Disables @pinia/nuxt
262
+ })
263
+ ```
264
+
265
+ ::note
266
+ The config key is defined by each module. Common examples include `image` for `@nuxt/image`, `pinia` for `@pinia/nuxt`, and `content` for `@nuxt/content`. Check the module's documentation for its specific config key.
267
+ ::
268
+
269
+ This is useful when:
270
+ - A layer includes modules you don't need in your project
271
+ - You want to use a different implementation than what the layer provides
272
+ - You need to disable analytics or other modules in specific environments
273
+
274
+ ::tip
275
+ You can also use this approach to disable modules in your own project - not just those from layers. Setting a module's config key to `false` will prevent its setup function from running while still generating types for the module.
276
+ ::
277
+
252
278
  ## Multi-Layer Support for Nuxt Modules
253
279
 
254
280
  You can use the [`getLayerDirectories`](/docs/4.x/api/kit/layers#getlayerdirectories) utility from Nuxt Kit to support custom multi-layer handling for your modules.
@@ -54,6 +54,10 @@ This component is experimental and in order to use it you must enable the `exper
54
54
  - **type**: `boolean`
55
55
  - **default**: `false`
56
56
 
57
+ ::warning{icon="i-ph-warning-duotone"}
58
+ The `placeholder` and `fallback` props render content as raw HTML. Do not pass untrusted user input to these props as it may lead to XSS vulnerabilities. Use the `#fallback` or `#placeholder` slots instead for dynamic content that needs proper escaping.
59
+ ::
60
+
57
61
  ```vue
58
62
  <template>
59
63
  <!-- render <span>Hello world</span> server-side if the default slot fails to render -->
@@ -32,13 +32,20 @@ Server only components use `<NuxtIsland>` under the hood
32
32
  - **type**: `Record<string, any>`
33
33
  - `source`: Remote source to call the island to render.
34
34
  - **type**: `string`
35
- - **dangerouslyLoadClientComponents**: Required to load components from a remote source.
35
+ - **dangerouslyLoadClientComponents**: Required to load client components from a remote source.
36
36
  - **type**: `boolean`
37
37
  - **default**: `false`
38
38
 
39
39
  ::note
40
40
  Remote islands need `experimental.componentIslands` to be `'local+remote'` in your `nuxt.config`.
41
- It is strongly discouraged to enable `dangerouslyLoadClientComponents` as you can't trust a remote server's javascript.
41
+ ::
42
+
43
+ ::warning{icon="i-ph-warning-duotone"}
44
+ Using the `source` prop to render content from a remote server is inherently dangerous. When you specify a remote `source`, you are fully trusting that server to provide safe HTML content that will be rendered directly in your application.
45
+
46
+ This is similar to using `v-html` with external content - the remote server can inject any HTML, including potentially malicious content. **Only use `source` with servers you fully trust and control.**
47
+
48
+ The `dangerouslyLoadClientComponents` prop controls an additional layer of risk: whether to also download and execute client components from the remote source. Even with `dangerouslyLoadClientComponents` disabled (the default), you are still trusting the remote server's HTML output.
42
49
  ::
43
50
 
44
51
  ::note
@@ -19,6 +19,42 @@ export default defineNuxtRouteMiddleware((to) => {
19
19
  })
20
20
  ```
21
21
 
22
+ ## Passing Props to Layouts
23
+
24
+ You can pass props to the layout by providing an object as the second argument:
25
+
26
+ ```ts [app/middleware/admin-layout.ts]
27
+ export default defineNuxtRouteMiddleware((to) => {
28
+ setPageLayout('admin', {
29
+ sidebar: true,
30
+ title: 'Dashboard',
31
+ })
32
+ })
33
+ ```
34
+
35
+ The layout can then receive these props:
36
+
37
+ ```vue [app/layouts/admin.vue]
38
+ <script setup lang="ts">
39
+ const props = defineProps<{
40
+ sidebar?: boolean
41
+ title?: string
42
+ }>()
43
+ </script>
44
+
45
+ <template>
46
+ <div>
47
+ <aside v-if="sidebar">
48
+ Sidebar
49
+ </aside>
50
+ <main>
51
+ <h1>{{ title }}</h1>
52
+ <slot />
53
+ </main>
54
+ </div>
55
+ </template>
56
+ ```
57
+
22
58
  ::note
23
59
  If you choose to set the layout dynamically on the server side, you _must_ do so before the layout is rendered by Vue (that is, within a plugin or route middleware) to avoid a hydration mismatch.
24
60
  ::
@@ -103,6 +103,19 @@ export default defineNuxtConfig({
103
103
  })
104
104
  ```
105
105
 
106
+ Users can also completely disable a module by setting the config key to `false`. This prevents the module's setup function from running while still generating types for module options.
107
+
108
+ ```ts
109
+ export default defineNuxtConfig({
110
+ // Disable the module entirely
111
+ myModule: false,
112
+ })
113
+ ```
114
+
115
+ ::tip
116
+ This is particularly useful when you want to disable modules inherited from [Nuxt layers](/docs/4.x/guide/going-further/layers#disabling-modules-from-layers).
117
+ ::
118
+
106
119
  #### Defining Module Compatibility Requirements
107
120
 
108
121
  If you're developing a Nuxt module and using APIs that are only supported in specific Nuxt versions, it's highly recommended to include `compatibility.nuxt`.
@@ -207,7 +207,19 @@ See [Vite website](https://vite.dev/guide/api-plugin) for more information about
207
207
 
208
208
  ### Parameters
209
209
 
210
- **`pluginOrGetter`**: A Vite plugin instance or an array of Vite plugin instances. If a function is provided, it must return a Vite plugin instance or an array of Vite plugin instances.
210
+ **`pluginOrGetter`**: A Vite plugin instance or an array of Vite plugin instances. If a function is provided, it must return a Vite plugin instance or an array of Vite plugin instances. The function can also be async or return a Promise, which is useful for lazy-loading plugins:
211
+
212
+ ```ts twoslash
213
+ // @errors: 2307
214
+ import { addVitePlugin, defineNuxtModule } from '@nuxt/kit'
215
+
216
+ export default defineNuxtModule({
217
+ setup () {
218
+ // Lazy load the plugin - only imported when the build actually runs
219
+ addVitePlugin(() => import('my-vite-plugin').then(r => r.default()))
220
+ },
221
+ })
222
+ ```
211
223
 
212
224
  **`options`**: Options to pass to the callback function. This object can have the following properties:
213
225
 
@@ -266,7 +278,7 @@ See [webpack website](https://webpack.js.org/concepts/plugins/) for more informa
266
278
 
267
279
  ### Parameters
268
280
 
269
- **`pluginOrGetter`**: A webpack plugin instance or an array of webpack plugin instances. If a function is provided, it must return a webpack plugin instance or an array of webpack plugin instances.
281
+ **`pluginOrGetter`**: A webpack plugin instance or an array of webpack plugin instances. If a function is provided, it must return a webpack plugin instance or an array of webpack plugin instances. The function can also be async or return a Promise, enabling lazy-loading of plugins.
270
282
 
271
283
  **`options`**: Options to pass to the callback function. This object can have the following properties:
272
284
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/docs-nightly",
3
- "version": "4.3.0-29481970.f136022c",
3
+ "version": "4.3.0-29483992.8d4f9ba5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",