@nuxt/docs 3.20.2 → 3.21.0

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.
Files changed (188) hide show
  1. package/1.getting-started/01.introduction.md +4 -4
  2. package/1.getting-started/02.installation.md +4 -7
  3. package/1.getting-started/03.configuration.md +29 -29
  4. package/1.getting-started/04.views.md +6 -4
  5. package/1.getting-started/05.assets.md +2 -2
  6. package/1.getting-started/06.styling.md +22 -16
  7. package/1.getting-started/07.routing.md +6 -6
  8. package/1.getting-started/08.seo-meta.md +8 -4
  9. package/1.getting-started/09.transitions.md +6 -6
  10. package/1.getting-started/10.data-fetching.md +18 -18
  11. package/1.getting-started/11.state-management.md +5 -5
  12. package/1.getting-started/12.error-handling.md +25 -19
  13. package/1.getting-started/13.server.md +9 -9
  14. package/1.getting-started/14.layers.md +49 -15
  15. package/1.getting-started/15.prerendering.md +10 -4
  16. package/1.getting-started/16.deployment.md +2 -1
  17. package/1.getting-started/17.testing.md +17 -7
  18. package/1.getting-started/18.upgrade.md +111 -60
  19. package/2.directory-structure/0.output.md +1 -1
  20. package/2.directory-structure/1.assets.md +1 -1
  21. package/2.directory-structure/1.components.md +12 -8
  22. package/2.directory-structure/1.composables.md +2 -2
  23. package/2.directory-structure/1.content.md +1 -1
  24. package/2.directory-structure/1.layers.md +87 -0
  25. package/2.directory-structure/1.layouts.md +35 -3
  26. package/2.directory-structure/1.middleware.md +7 -7
  27. package/2.directory-structure/1.modules.md +8 -2
  28. package/2.directory-structure/1.node_modules.md +1 -1
  29. package/2.directory-structure/1.pages.md +39 -18
  30. package/2.directory-structure/1.plugins.md +4 -1
  31. package/2.directory-structure/1.public.md +1 -1
  32. package/2.directory-structure/1.server.md +28 -8
  33. package/2.directory-structure/1.shared.md +3 -3
  34. package/2.directory-structure/1.utils.md +2 -2
  35. package/2.directory-structure/2.env.md +3 -3
  36. package/2.directory-structure/2.nuxtignore.md +1 -0
  37. package/2.directory-structure/2.nuxtrc.md +5 -2
  38. package/2.directory-structure/3.app-config.md +2 -2
  39. package/2.directory-structure/3.app.md +3 -3
  40. package/2.directory-structure/3.error.md +9 -5
  41. package/2.directory-structure/3.nuxt-config.md +1 -1
  42. package/2.directory-structure/3.package.md +1 -1
  43. package/2.directory-structure/3.tsconfig.md +3 -2
  44. package/2.directory-structure/index.md +12 -8
  45. package/3.guide/0.index.md +8 -2
  46. package/3.guide/1.concepts/{3.rendering.md → 1.rendering.md} +7 -32
  47. package/3.guide/1.concepts/{2.vuejs-development.md → 10.vuejs-development.md} +9 -8
  48. package/3.guide/1.concepts/{10.nuxt-lifecycle.md → 2.nuxt-lifecycle.md} +31 -24
  49. package/3.guide/1.concepts/{1.auto-imports.md → 3.auto-imports.md} +6 -6
  50. package/3.guide/1.concepts/4.server-engine.md +2 -2
  51. package/3.guide/1.concepts/5.modules.md +14 -1
  52. package/3.guide/1.concepts/7.esm.md +5 -4
  53. package/3.guide/1.concepts/8.typescript.md +9 -15
  54. package/3.guide/1.concepts/9.code-style.md +1 -1
  55. package/3.guide/2.best-practices/hydration.md +1 -1
  56. package/3.guide/2.best-practices/performance.md +5 -5
  57. package/3.guide/3.ai/.navigation.yml +3 -0
  58. package/3.guide/3.ai/1.mcp.md +277 -0
  59. package/3.guide/3.ai/2.llms-txt.md +65 -0
  60. package/3.guide/4.modules/.navigation.yml +3 -0
  61. package/3.guide/4.modules/1.getting-started.md +103 -0
  62. package/3.guide/4.modules/2.module-anatomy.md +138 -0
  63. package/3.guide/4.modules/3.recipes-basics.md +330 -0
  64. package/3.guide/4.modules/4.recipes-advanced.md +243 -0
  65. package/3.guide/4.modules/5.testing.md +76 -0
  66. package/3.guide/4.modules/6.best-practices.md +104 -0
  67. package/3.guide/4.modules/7.ecosystem.md +32 -0
  68. package/3.guide/4.modules/index.md +36 -0
  69. package/3.guide/{3.recipes → 5.recipes}/1.custom-routing.md +3 -3
  70. package/3.guide/{3.recipes → 5.recipes}/2.vite-plugin.md +4 -0
  71. package/3.guide/{3.recipes → 5.recipes}/3.custom-usefetch.md +2 -2
  72. package/3.guide/{3.recipes → 5.recipes}/4.sessions-and-authentication.md +2 -2
  73. package/3.guide/{4.going-further → 6.going-further}/1.events.md +3 -4
  74. package/3.guide/{4.going-further → 6.going-further}/1.experimental-features.md +211 -86
  75. package/3.guide/6.going-further/1.features.md +108 -0
  76. package/3.guide/{4.going-further → 6.going-further}/1.internals.md +4 -3
  77. package/3.guide/{4.going-further → 6.going-further}/10.runtime-config.md +2 -2
  78. package/3.guide/{4.going-further → 6.going-further}/11.nightly-release-channel.md +1 -1
  79. package/3.guide/{4.going-further → 6.going-further}/2.hooks.md +5 -5
  80. package/3.guide/{4.going-further → 6.going-further}/4.kit.md +3 -3
  81. package/3.guide/{4.going-further → 6.going-further}/6.nuxt-app.md +6 -6
  82. package/3.guide/{4.going-further → 6.going-further}/7.layers.md +31 -5
  83. package/3.guide/{4.going-further → 6.going-further}/9.debugging.md +3 -2
  84. package/4.api/1.components/1.nuxt-client-fallback.md +5 -1
  85. package/4.api/1.components/10.nuxt-picture.md +1 -1
  86. package/4.api/1.components/11.teleports.md +2 -2
  87. package/4.api/1.components/12.nuxt-route-announcer.md +0 -2
  88. package/4.api/1.components/13.nuxt-time.md +0 -2
  89. package/4.api/1.components/2.nuxt-page.md +3 -3
  90. package/4.api/1.components/3.nuxt-layout.md +6 -6
  91. package/4.api/1.components/4.nuxt-link.md +13 -13
  92. package/4.api/1.components/5.nuxt-loading-indicator.md +1 -1
  93. package/4.api/1.components/6.nuxt-error-boundary.md +2 -2
  94. package/4.api/1.components/7.nuxt-welcome.md +2 -2
  95. package/4.api/1.components/8.nuxt-island.md +9 -2
  96. package/4.api/2.composables/use-app-config.md +1 -1
  97. package/4.api/2.composables/use-async-data.md +5 -5
  98. package/4.api/2.composables/use-cookie.md +16 -16
  99. package/4.api/2.composables/use-error.md +3 -3
  100. package/4.api/2.composables/use-fetch.md +37 -37
  101. package/4.api/2.composables/use-head-safe.md +1 -1
  102. package/4.api/2.composables/use-head.md +22 -7
  103. package/4.api/2.composables/use-lazy-async-data.md +1 -1
  104. package/4.api/2.composables/use-lazy-fetch.md +9 -9
  105. package/4.api/2.composables/use-nuxt-app.md +9 -7
  106. package/4.api/2.composables/use-route-announcer.md +0 -2
  107. package/4.api/2.composables/use-route.md +2 -2
  108. package/4.api/2.composables/use-router.md +15 -15
  109. package/4.api/2.composables/use-runtime-config.md +5 -5
  110. package/4.api/2.composables/use-seo-meta.md +2 -2
  111. package/4.api/2.composables/use-server-seo-meta.md +2 -2
  112. package/4.api/2.composables/use-state.md +12 -2
  113. package/4.api/3.utils/$fetch.md +1 -1
  114. package/4.api/3.utils/abort-navigation.md +2 -2
  115. package/4.api/3.utils/call-once.md +2 -4
  116. package/4.api/3.utils/clear-error.md +1 -1
  117. package/4.api/3.utils/create-error.md +7 -7
  118. package/4.api/3.utils/define-lazy-hydration-component.md +5 -5
  119. package/4.api/3.utils/define-nuxt-component.md +1 -1
  120. package/4.api/3.utils/define-nuxt-plugin.md +12 -12
  121. package/4.api/3.utils/define-nuxt-route-middleware.md +2 -2
  122. package/4.api/3.utils/define-page-meta.md +18 -11
  123. package/4.api/3.utils/define-route-rules.md +2 -2
  124. package/4.api/3.utils/navigate-to.md +14 -14
  125. package/4.api/3.utils/on-before-route-leave.md +1 -1
  126. package/4.api/3.utils/on-before-route-update.md +1 -1
  127. package/4.api/3.utils/preload-route-components.md +2 -2
  128. package/4.api/3.utils/refresh-cookie.md +0 -2
  129. package/4.api/3.utils/refresh-nuxt-data.md +1 -1
  130. package/4.api/3.utils/reload-nuxt-app.md +1 -1
  131. package/4.api/3.utils/set-page-layout.md +36 -0
  132. package/4.api/3.utils/set-response-status.md +3 -3
  133. package/4.api/3.utils/show-error.md +4 -4
  134. package/4.api/3.utils/update-app-config.md +1 -1
  135. package/4.api/4.commands/add.md +11 -11
  136. package/4.api/4.commands/analyze.md +11 -11
  137. package/4.api/4.commands/build-module.md +11 -11
  138. package/4.api/4.commands/build.md +12 -12
  139. package/4.api/4.commands/cleanup.md +6 -6
  140. package/4.api/4.commands/dev.md +23 -23
  141. package/4.api/4.commands/devtools.md +7 -7
  142. package/4.api/4.commands/generate.md +12 -12
  143. package/4.api/4.commands/info.md +6 -6
  144. package/4.api/4.commands/init.md +18 -18
  145. package/4.api/4.commands/module.md +18 -18
  146. package/4.api/4.commands/prepare.md +10 -10
  147. package/4.api/4.commands/preview.md +11 -11
  148. package/4.api/4.commands/test.md +9 -9
  149. package/4.api/4.commands/typecheck.md +10 -10
  150. package/4.api/4.commands/upgrade.md +10 -10
  151. package/4.api/5.kit/1.modules.md +31 -18
  152. package/4.api/5.kit/10.templates.md +23 -23
  153. package/4.api/5.kit/11.nitro.md +36 -36
  154. package/4.api/5.kit/12.resolving.md +2 -2
  155. package/4.api/5.kit/14.builder.md +35 -23
  156. package/4.api/5.kit/16.layers.md +16 -16
  157. package/4.api/5.kit/2.programmatic.md +2 -2
  158. package/4.api/5.kit/3.compatibility.md +2 -2
  159. package/4.api/5.kit/4.autoimports.md +18 -18
  160. package/4.api/5.kit/5.components.md +35 -35
  161. package/4.api/5.kit/6.context.md +1 -1
  162. package/4.api/5.kit/8.layout.md +1 -1
  163. package/4.api/6.advanced/1.hooks.md +85 -85
  164. package/4.api/index.md +7 -7
  165. package/5.community/4.contribution.md +10 -10
  166. package/5.community/5.framework-contribution.md +9 -9
  167. package/5.community/6.roadmap.md +25 -25
  168. package/5.community/7.changelog.md +10 -0
  169. package/6.bridge/1.overview.md +8 -0
  170. package/6.bridge/3.bridge-composition-api.md +2 -2
  171. package/6.bridge/4.plugins-and-middleware.md +2 -2
  172. package/6.bridge/5.nuxt3-compatible-api.md +1 -1
  173. package/6.bridge/8.nitro.md +4 -0
  174. package/7.migration/10.bundling.md +1 -1
  175. package/7.migration/11.server.md +3 -3
  176. package/7.migration/2.configuration.md +5 -5
  177. package/7.migration/20.module-authors.md +3 -3
  178. package/7.migration/4.meta.md +1 -1
  179. package/7.migration/5.plugins-and-middleware.md +3 -3
  180. package/7.migration/6.pages-and-layouts.md +5 -5
  181. package/7.migration/7.component-options.md +6 -6
  182. package/7.migration/8.runtime-config.md +1 -1
  183. package/package.json +1 -1
  184. package/3.guide/4.going-further/1.features.md +0 -103
  185. package/3.guide/4.going-further/3.modules.md +0 -901
  186. /package/3.guide/{3.recipes → 5.recipes}/.navigation.yml +0 -0
  187. /package/3.guide/{4.going-further → 6.going-further}/.navigation.yml +0 -0
  188. /package/3.guide/{4.going-further → 6.going-further}/index.md +0 -0
@@ -48,14 +48,14 @@ function addTemplate (template: NuxtTemplate | string): ResolvedNuxtTemplate
48
48
 
49
49
  **template**: A template object or a string with the path to the template. If a string is provided, it will be converted to a template object with `src` set to the string value. If a template object is provided, it must have the following properties:
50
50
 
51
- | Property | Type | Required | Description |
52
- | ---------- | -------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
53
- | `src` | `string` | `false` | Path to the template. If `src` is not provided, `getContents` must be provided instead. |
54
- | `filename` | `string` | `false` | Filename of the template. If `filename` is not provided, it will be generated from the `src` path. In this case, the `src` option is required. |
55
- | `dst` | `string` | `false` | Path to the destination file. If `dst` is not provided, it will be generated from the `filename` path and nuxt `buildDir` option. |
56
- | `options` | `Options` | `false` | Options to pass to the template. |
51
+ | Property | Type | Required | Description |
52
+ |---------------|-----------------------------------------------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
53
+ | `src` | `string` | `false` | Path to the template. If `src` is not provided, `getContents` must be provided instead. |
54
+ | `filename` | `string` | `false` | Filename of the template. If `filename` is not provided, it will be generated from the `src` path. In this case, the `src` option is required. |
55
+ | `dst` | `string` | `false` | Path to the destination file. If `dst` is not provided, it will be generated from the `filename` path and nuxt `buildDir` option. |
56
+ | `options` | `Options` | `false` | Options to pass to the template. |
57
57
  | `getContents` | `(data: Options) => string \| Promise<string>`{lang="ts"} | `false` | A function that will be called with the `options` object. It should return a string or a promise that resolves to a string. If `src` is provided, this function will be ignored. |
58
- | `write` | `boolean` | `false` | If set to `true`, the template will be written to the destination file. Otherwise, the template will be used only in virtual filesystem. |
58
+ | `write` | `boolean` | `false` | If set to `true`, the template will be written to the destination file. Otherwise, the template will be used only in virtual filesystem. |
59
59
 
60
60
  ### Examples
61
61
 
@@ -133,20 +133,20 @@ function addTypeTemplate (template: NuxtTypeTemplate | string, context?: { nitro
133
133
 
134
134
  **template**: A template object or a string with the path to the template. If a string is provided, it will be converted to a template object with `src` set to the string value. If a template object is provided, it must have the following properties:
135
135
 
136
- | Property | Type | Required | Description |
137
- | ---------- | -------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
138
- | `src` | `string` | `false` | Path to the template. If `src` is not provided, `getContents` must be provided instead. |
139
- | `filename` | `string` | `false` | Filename of the template. If `filename` is not provided, it will be generated from the `src` path. In this case, the `src` option is required. |
140
- | `dst` | `string` | `false` | Path to the destination file. If `dst` is not provided, it will be generated from the `filename` path and nuxt `buildDir` option. |
141
- | `options` | `Options` | `false` | Options to pass to the template. |
136
+ | Property | Type | Required | Description |
137
+ |---------------|-----------------------------------------------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
138
+ | `src` | `string` | `false` | Path to the template. If `src` is not provided, `getContents` must be provided instead. |
139
+ | `filename` | `string` | `false` | Filename of the template. If `filename` is not provided, it will be generated from the `src` path. In this case, the `src` option is required. |
140
+ | `dst` | `string` | `false` | Path to the destination file. If `dst` is not provided, it will be generated from the `filename` path and nuxt `buildDir` option. |
141
+ | `options` | `Options` | `false` | Options to pass to the template. |
142
142
  | `getContents` | `(data: Options) => string \| Promise<string>`{lang="ts"} | `false` | A function that will be called with the `options` object. It should return a string or a promise that resolves to a string. If `src` is provided, this function will be ignored. |
143
143
 
144
144
  **context**: An optional context object can be passed to control where the type is added. If omitted, the type will only be added to the Nuxt context. This object supports the following properties:
145
145
 
146
- | Property | Type | Required | Description |
147
- | ---------- | -------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
148
- | `nuxt` | `boolean` | `false` | If set to `true`, the type will be added to the Nuxt context. |
149
- | `nitro` | `boolean` | `false` | If set to `true`, the type will be added to the Nitro context. |
146
+ | Property | Type | Required | Description |
147
+ |----------|-----------|----------|----------------------------------------------------------------|
148
+ | `nuxt` | `boolean` | `false` | If set to `true`, the type will be added to the Nuxt context. |
149
+ | `nitro` | `boolean` | `false` | If set to `true`, the type will be added to the Nitro context. |
150
150
 
151
151
  ### Examples
152
152
 
@@ -226,9 +226,9 @@ function addServerTemplate (template: NuxtServerTemplate): NuxtServerTemplate
226
226
 
227
227
  **template**: A template object. It must have the following properties:
228
228
 
229
- | Property | Type | Required | Description |
230
- | ------------- | ---------------------------------------------| -------- | --------------------------------------------------------------------------------------------------------------- |
231
- | `filename` | `string` | `true` | Filename of the template. |
229
+ | Property | Type | Required | Description |
230
+ |---------------|----------------------------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------|
231
+ | `filename` | `string` | `true` | Filename of the template. |
232
232
  | `getContents` | `() => string \| Promise<string>`{lang="ts"} | `true` | A function that will be called with the `options` object. It should return a string or a promise that resolves to a string. |
233
233
 
234
234
  ### Examples
@@ -304,6 +304,6 @@ async function updateTemplates (options: UpdateTemplatesOptions): void
304
304
 
305
305
  **options**: Options to pass to the template. This object can have the following property:
306
306
 
307
- | Property | Type | Required | Description |
308
- | ---------- | -------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
309
- | `filter` | `(template: ResolvedNuxtTemplate) => boolean`{lang="ts"} | `false` | A function that will be called with the `template` object. It should return a boolean indicating whether the template should be regenerated. If `filter` is not provided, all templates will be regenerated. |
307
+ | Property | Type | Required | Description |
308
+ |----------|----------------------------------------------------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
309
+ | `filter` | `(template: ResolvedNuxtTemplate) => boolean`{lang="ts"} | `false` | A function that will be called with the `template` object. It should return a boolean indicating whether the template should be regenerated. If `filter` is not provided, all templates will be regenerated. |
@@ -41,13 +41,13 @@ function addServerHandler (handler: NitroEventHandler): void
41
41
 
42
42
  **handler**: A handler object with the following properties:
43
43
 
44
- | Property | Type | Required | Description |
45
- | ----------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
46
- | `handler` | `string` | `true` | Path to event handler. |
47
- | `route` | `string` | `false` | Path prefix or route. If an empty string used, will be used as a middleware. |
48
- | `middleware`| `boolean` | `false` | Specifies this is a middleware handler. Middleware are called on every route and should normally return nothing to pass to the next handlers. |
49
- | `lazy` | `boolean` | `false` | Use lazy loading to import the handler. This is useful when you only want to load the handler on demand. |
50
- | `method` | `string` | `false` | Router method matcher. If handler name contains method name, it will be used as a default value. |
44
+ | Property | Type | Required | Description |
45
+ |--------------|-----------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------|
46
+ | `handler` | `string` | `true` | Path to event handler. |
47
+ | `route` | `string` | `false` | Path prefix or route. If an empty string used, will be used as a middleware. |
48
+ | `middleware` | `boolean` | `false` | Specifies this is a middleware handler. Middleware are called on every route and should normally return nothing to pass to the next handlers. |
49
+ | `lazy` | `boolean` | `false` | Use lazy loading to import the handler. This is useful when you only want to load the handler on demand. |
50
+ | `method` | `string` | `false` | Router method matcher. If handler name contains method name, it will be used as a default value. |
51
51
 
52
52
  ### Examples
53
53
 
@@ -117,7 +117,7 @@ export default defineNuxtModule({
117
117
 
118
118
  ```ts twoslash
119
119
  // @errors: 2391
120
- import type { NitroDevEventHandler } from 'nitropack'
120
+ import type { NitroDevEventHandler } from 'nitropack/types'
121
121
  // ---cut---
122
122
  function addDevServerHandler (handler: NitroDevEventHandler): void
123
123
  ```
@@ -126,10 +126,10 @@ function addDevServerHandler (handler: NitroDevEventHandler): void
126
126
 
127
127
  **handler**: A handler object with the following properties:
128
128
 
129
- | Property | Type | Required | Description |
130
- | ----------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
131
- | `handler` | `EventHandler` | `true` | Event handler. |
132
- | `route` | `string` | `false` | Path prefix or route. If an empty string used, will be used as a middleware. |
129
+ | Property | Type | Required | Description |
130
+ |-----------|----------------|----------|------------------------------------------------------------------------------|
131
+ | `handler` | `EventHandler` | `true` | Event handler. |
132
+ | `route` | `string` | `false` | Path prefix or route. If an empty string used, will be used as a middleware. |
133
133
 
134
134
  ### Examples
135
135
 
@@ -222,9 +222,9 @@ function addServerPlugin (plugin: string): void
222
222
 
223
223
  ### Parameters
224
224
 
225
- | Property | Type | Required | Description |
226
- | ----------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
227
- | `plugin` | `string` | `true` | Path to the plugin. The plugin must export a default function that accepts the Nitro instance as an argument. |
225
+ | Property | Type | Required | Description |
226
+ |----------|----------|----------|---------------------------------------------------------------------------------------------------------------|
227
+ | `plugin` | `string` | `true` | Path to the plugin. The plugin must export a default function that accepts the Nitro instance as an argument. |
228
228
 
229
229
  ### Examples
230
230
 
@@ -293,9 +293,9 @@ function addPrerenderRoutes (routes: string | string[]): void
293
293
 
294
294
  ### Parameters
295
295
 
296
- | Property | Type | Required | Description |
297
- | ----------- | ------------------------------- | -------- | ---------------------------------------------- |
298
- | `routes` | `string \| string[]`{lang="ts"} | `true` | A route or an array of routes to prerender. |
296
+ | Property | Type | Required | Description |
297
+ |----------|---------------------------------|----------|---------------------------------------------|
298
+ | `routes` | `string \| string[]`{lang="ts"} | `true` | A route or an array of routes to prerender. |
299
299
 
300
300
  ## `addServerImports`
301
301
 
@@ -333,16 +333,16 @@ function addServerImports (dirs: Import | Import[]): void
333
333
 
334
334
  `imports`: An object or an array of objects with the following properties:
335
335
 
336
- | Property | Type | Required | Description |
337
- | ------------------ | ---------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
338
- | `name` | `string` | `true` | Import name to be detected. |
339
- | `from` | `string` | `true` | Module specifier to import from. |
340
- | `priority` | `number` | `false` | Priority of the import; if multiple imports have the same name, the one with the highest priority will be used. |
341
- | `disabled` | `boolean` | `false` | If this import is disabled. |
342
- | `meta` | `Record<string, any>` | `false` | Metadata of the import. |
343
- | `type` | `boolean` | `false` | If this import is a pure type import. |
344
- | `typeFrom` | `string` | `false` | Use this as the `from` value when generating type declarations. |
345
- | `as` | `string` | `false` | Import as this name. |
336
+ | Property | Type | Required | Description |
337
+ |------------|-----------------------|----------|-----------------------------------------------------------------------------------------------------------------|
338
+ | `name` | `string` | `true` | Import name to be detected. |
339
+ | `from` | `string` | `true` | Module specifier to import from. |
340
+ | `priority` | `number` | `false` | Priority of the import; if multiple imports have the same name, the one with the highest priority will be used. |
341
+ | `disabled` | `boolean` | `false` | If this import is disabled. |
342
+ | `meta` | `Record<string, any>` | `false` | Metadata of the import. |
343
+ | `type` | `boolean` | `false` | If this import is a pure type import. |
344
+ | `typeFrom` | `string` | `false` | Use this as the `from` value when generating type declarations. |
345
+ | `as` | `string` | `false` | Import as this name. |
346
346
 
347
347
  ## `addServerImportsDir`
348
348
 
@@ -373,10 +373,10 @@ function addServerImportsDir (dirs: string | string[], opts: { prepend?: boolean
373
373
 
374
374
  ### Parameters
375
375
 
376
- | Property | Type | Required | Description |
377
- | ----------- | ------------------------------- | -------- | ---------------------------------------------- |
378
- | `dirs` | `string \| string[]`{lang="ts"} | `true` | A directory or an array of directories to register to be scanned by Nitro. |
379
- | `opts` | `{ prepend?: boolean }` | `false` | Options for the import directory. If `prepend` is `true`, the directory is added to the beginning of the scan list. |
376
+ | Property | Type | Required | Description |
377
+ |----------|---------------------------------|----------|---------------------------------------------------------------------------------------------------------------------|
378
+ | `dirs` | `string \| string[]`{lang="ts"} | `true` | A directory or an array of directories to register to be scanned by Nitro. |
379
+ | `opts` | `{ prepend?: boolean }` | `false` | Options for the import directory. If `prepend` is `true`, the directory is added to the beginning of the scan list. |
380
380
 
381
381
  ### Examples
382
382
 
@@ -453,10 +453,10 @@ function addServerScanDir (dirs: string | string[], opts: { prepend?: boolean })
453
453
 
454
454
  ### Parameters
455
455
 
456
- | Property | Type | Required | Description |
457
- | ----------- | ------------------------------- | -------- | ---------------------------------------------- |
458
- | `dirs` | `string \| string[]`{lang="ts"} | `true` | A directory or an array of directories to register to be scanned for by Nitro as server dirs. |
459
- | `opts` | `{ prepend?: boolean }` | `false` | Options for the import directory. If `prepend` is `true`, the directory is added to the beginning of the scan list. |
456
+ | Property | Type | Required | Description |
457
+ |----------|---------------------------------|----------|---------------------------------------------------------------------------------------------------------------------|
458
+ | `dirs` | `string \| string[]`{lang="ts"} | `true` | A directory or an array of directories to register to be scanned for by Nitro as server dirs. |
459
+ | `opts` | `{ prepend?: boolean }` | `false` | Options for the import directory. If `prepend` is `true`, the directory is added to the beginning of the scan list. |
460
460
 
461
461
  ### Examples
462
462
 
@@ -8,11 +8,11 @@ links:
8
8
  size: xs
9
9
  ---
10
10
 
11
- Sometimes you need to resolve a paths: relative to the current module, with unknown name or extension. For example, you may want to add a plugin that is located in the same directory as the module. To handle this cases, nuxt provides a set of utilities to resolve paths. `resolvePath` and `resolveAlias` are used to resolve paths relative to the current module. `findPath` is used to find first existing file in given paths. `createResolver` is used to create resolver relative to base path.
11
+ Sometimes you need to resolve a path relative to the current module without knowing the name or extension. For example, you may want to add a plugin that is located in the same directory as the module. To handle these cases, Nuxt provides a set of utilities to resolve paths. `resolvePath` and `resolveAlias` are used to resolve paths relative to the current module. `findPath` is used to find the first existing file in a given set of paths. `createResolver` is used to create a resolver relative to the base path.
12
12
 
13
13
  ## `resolvePath`
14
14
 
15
- Resolves full path to a file or directory respecting Nuxt alias and extensions options. If path could not be resolved, normalized input path will be returned.
15
+ Resolves the full path to a file or directory, respecting Nuxt alias and extensions options. If a path could not be resolved, a normalized input path will be returned.
16
16
 
17
17
  ### Usage
18
18
 
@@ -83,8 +83,8 @@ import type { ExtendViteConfigOptions } from '@nuxt/kit'
83
83
  function extendViteConfig (callback: ((config: ViteConfig) => void), options?: ExtendViteConfigOptions): void
84
84
  ```
85
85
 
86
- ::read-more{to="https://vite.dev/config" target="_blank" icon="i-simple-icons-vite"}
87
- Checkout Vite website for more information about its configuration.
86
+ ::read-more{to="https://vite.dev/config/" target="_blank" icon="i-simple-icons-vite"}
87
+ Check out the Vite website for more information about its configuration.
88
88
  ::
89
89
 
90
90
  ### Parameters
@@ -93,13 +93,13 @@ Checkout Vite website for more information about its configuration.
93
93
 
94
94
  **`options`**: Options to pass to the callback function. This object can have the following properties:
95
95
 
96
- | Property | Type | Required | Description |
97
- | --------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------ |
98
- | `dev` | `boolean` | `false` | If set to `true`, the callback function will be called when building in development mode. |
99
- | `build` | `boolean` | `false` | If set to `true`, the callback function will be called when building in production mode. |
96
+ | Property | Type | Required | Description |
97
+ |-----------|-----------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
98
+ | `dev` | `boolean` | `false` | If set to `true`, the callback function will be called when building in development mode. |
99
+ | `build` | `boolean` | `false` | If set to `true`, the callback function will be called when building in production mode. |
100
100
  | `server` | `boolean` | `false` | If set to `true`, the callback function will be called when building the server bundle. **Deprecated in Nuxt 5+.** Use `addVitePlugin()` with `applyToEnvironment()` instead. |
101
101
  | `client` | `boolean` | `false` | If set to `true`, the callback function will be called when building the client bundle. **Deprecated in Nuxt 5+.** Use `addVitePlugin()` with `applyToEnvironment()` instead. |
102
- | `prepend` | `boolean` | `false` | If set to `true`, the callback function will be prepended to the array with `unshift()` instead of `push()`. |
102
+ | `prepend` | `boolean` | `false` | If set to `true`, the callback function will be prepended to the array with `unshift()` instead of `push()`. |
103
103
 
104
104
  ## `extendWebpackConfig`
105
105
 
@@ -132,8 +132,8 @@ import type { ExtendWebpackConfigOptions } from '@nuxt/kit'
132
132
  function extendWebpackConfig (callback: ((config: WebpackConfig) => void), options?: ExtendWebpackConfigOptions): void
133
133
  ```
134
134
 
135
- ::read-more{to="https://webpack.js.org/configuration" target="_blank" icon="i-simple-icons-webpack"}
136
- Checkout webpack website for more information about its configuration.
135
+ ::read-more{to="https://webpack.js.org/configuration/" target="_blank" icon="i-simple-icons-webpack"}
136
+ Check out webpack website for more information about its configuration.
137
137
  ::
138
138
 
139
139
  ### Parameters
@@ -143,7 +143,7 @@ Checkout webpack website for more information about its configuration.
143
143
  **`options`**: Options to pass to the callback function. This object can have the following properties:
144
144
 
145
145
  | Property | Type | Required | Description |
146
- | --------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------ |
146
+ |-----------|-----------|----------|--------------------------------------------------------------------------------------------------------------|
147
147
  | `dev` | `boolean` | `false` | If set to `true`, the callback function will be called when building in development mode. |
148
148
  | `build` | `boolean` | `false` | If set to `true`, the callback function will be called when building in production mode. |
149
149
  | `server` | `boolean` | `false` | If set to `true`, the callback function will be called when building the server bundle. |
@@ -202,22 +202,34 @@ function addVitePlugin (pluginOrGetter: VitePlugin | VitePlugin[] | (() => ViteP
202
202
  ```
203
203
 
204
204
  ::tip
205
- See [Vite website](https://vite.dev/guide/api-plugin.html) for more information about Vite plugins. You can also use [this repository](https://github.com/vitejs/awesome-vite#plugins) to find a plugin that suits your needs.
205
+ See [Vite website](https://vite.dev/guide/api-plugin) for more information about Vite plugins. You can also use [this repository](https://github.com/vitejs/awesome-vite#plugins) to find a plugin that suits your needs.
206
206
  ::
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
 
214
- | Property | Type | Required | Description |
215
- | --------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------ |
216
- | `dev` | `boolean` | `false` | If set to `true`, the callback function will be called when building in development mode. |
217
- | `build` | `boolean` | `false` | If set to `true`, the callback function will be called when building in production mode. |
226
+ | Property | Type | Required | Description |
227
+ |-----------|-----------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
228
+ | `dev` | `boolean` | `false` | If set to `true`, the callback function will be called when building in development mode. |
229
+ | `build` | `boolean` | `false` | If set to `true`, the callback function will be called when building in production mode. |
218
230
  | `server` | `boolean` | `false` | If set to `true`, the callback function will be called when building the server bundle. **Deprecated in Nuxt 5+.** Use `applyToEnvironment()` instead. |
219
231
  | `client` | `boolean` | `false` | If set to `true`, the callback function will be called when building the client bundle. **Deprecated in Nuxt 5+.** Use `applyToEnvironment()` instead. |
220
- | `prepend` | `boolean` | `false` | If set to `true`, the callback function will be prepended to the array with `unshift()` instead of `push()`. |
232
+ | `prepend` | `boolean` | `false` | If set to `true`, the callback function will be prepended to the array with `unshift()` instead of `push()`. |
221
233
 
222
234
  ## `addWebpackPlugin`
223
235
 
@@ -261,17 +273,17 @@ function addWebpackPlugin (pluginOrGetter: WebpackPluginInstance | WebpackPlugin
261
273
  ```
262
274
 
263
275
  ::tip
264
- See [webpack website](https://webpack.js.org/concepts/plugins) for more information about webpack plugins. You can also use [this collection](https://webpack.js.org/awesome-webpack/#webpack-plugins) to find a plugin that suits your needs.
276
+ See [webpack website](https://webpack.js.org/concepts/plugins/) for more information about webpack plugins. You can also use [this collection](https://webpack.js.org/awesome-webpack/#webpack-plugins) to find a plugin that suits your needs.
265
277
  ::
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
 
273
- | Property | Type | Required | Description |
274
- | --------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------ |
285
+ | Property | Type | Required | Description |
286
+ |-----------|-----------|----------|--------------------------------------------------------------------------------------------------------------|
275
287
  | `dev` | `boolean` | `false` | If set to `true`, the callback function will be called when building in development mode. |
276
288
  | `build` | `boolean` | `false` | If set to `true`, the callback function will be called when building in production mode. |
277
289
  | `server` | `boolean` | `false` | If set to `true`, the callback function will be called when building the server bundle. |
@@ -306,8 +318,8 @@ function addBuildPlugin (pluginFactory: AddBuildPluginFactory, options?: ExtendC
306
318
 
307
319
  **`options`**: Options to pass to the callback function. This object can have the following properties:
308
320
 
309
- | Property | Type | Required | Description |
310
- | --------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------ |
321
+ | Property | Type | Required | Description |
322
+ |-----------|-----------|----------|--------------------------------------------------------------------------------------------------------------|
311
323
  | `dev` | `boolean` | `false` | If set to `true`, the callback function will be called when building in development mode. |
312
324
  | `build` | `boolean` | `false` | If set to `true`, the callback function will be called when building in production mode. |
313
325
  | `server` | `boolean` | `false` | If set to `true`, the callback function will be called when building the server bundle. |
@@ -57,13 +57,13 @@ interface LayerDirectories {
57
57
  readonly public: string
58
58
  /** Nuxt srcDir (`/app/` by default) */
59
59
  readonly app: string
60
- /** Layouts directory (`/app/layouts` by default) */
60
+ /** Layouts directory (`/layouts` by default) */
61
61
  readonly appLayouts: string
62
- /** Middleware directory (`/app/middleware` by default) */
62
+ /** Middleware directory (`/middleware` by default) */
63
63
  readonly appMiddleware: string
64
- /** Pages directory (`/app/pages` by default) */
64
+ /** Pages directory (`/pages` by default) */
65
65
  readonly appPages: string
66
- /** Plugins directory (`/app/plugins` by default) */
66
+ /** Plugins directory (`/plugins` by default) */
67
67
  readonly appPlugins: string
68
68
  }
69
69
  ```
@@ -85,18 +85,18 @@ This ordering matches Nuxt's layer resolution system, where user-defined configu
85
85
 
86
86
  **`LayerDirectories`**: An object containing the resolved directory paths for a layer.
87
87
 
88
- | Property | Type | Description |
89
- | --------------- | -------- | ------------------------------------------------------------------------------ |
90
- | `root` | `string` | The root directory of the layer (equivalent to `rootDir`) |
91
- | `server` | `string` | The server directory for Nitro server-side code |
92
- | `modules` | `string` | The local modules directory |
93
- | `shared` | `string` | The shared directory for code used by both client and server |
94
- | `app` | `string` | The source directory of the layer (equivalent to `srcDir`) |
95
- | `public` | `string` | The public directory for static assets |
96
- | `appLayouts` | `string` | The layouts directory for Vue layout components |
97
- | `appMiddleware` | `string` | The middleware directory for route middleware |
98
- | `appPages` | `string` | The pages directory for file-based routing |
99
- | `appPlugins` | `string` | The plugins directory for Nuxt plugins |
88
+ | Property | Type | Description |
89
+ |-----------------|----------|--------------------------------------------------------------|
90
+ | `root` | `string` | The root directory of the layer (equivalent to `rootDir`) |
91
+ | `server` | `string` | The server directory for Nitro server-side code |
92
+ | `modules` | `string` | The local modules directory |
93
+ | `shared` | `string` | The shared directory for code used by both client and server |
94
+ | `app` | `string` | The source directory of the layer (equivalent to `srcDir`) |
95
+ | `public` | `string` | The public directory for static assets |
96
+ | `appLayouts` | `string` | The layouts directory for Vue layout components |
97
+ | `appMiddleware` | `string` | The middleware directory for route middleware |
98
+ | `appPages` | `string` | The pages directory for file-based routing |
99
+ | `appPlugins` | `string` | The plugins directory for Nuxt plugins |
100
100
 
101
101
  ### Examples
102
102
 
@@ -4,7 +4,7 @@ description: Nuxt Kit provides a set of utilities to help you work with Nuxt pro
4
4
  links:
5
5
  - label: Source
6
6
  icon: i-simple-icons-github
7
- to: https://github.com/nuxt/nuxt/blob/main/packages/kit/src/loader
7
+ to: https://github.com/nuxt/nuxt/tree/main/packages/kit/src/loader
8
8
  size: xs
9
9
  ---
10
10
 
@@ -31,7 +31,7 @@ function loadNuxt (loadOptions?: LoadNuxtOptions): Promise<Nuxt>
31
31
 
32
32
  ## `buildNuxt`
33
33
 
34
- Build Nuxt programmatically. It will invoke the builder (currently [@nuxt/vite-builder](https://github.com/nuxt/nuxt/blob/main/packages/vite) or [@nuxt/webpack-builder](https://github.com/nuxt/nuxt/blob/main/packages/webpack)) to bundle the application.
34
+ Build Nuxt programmatically. It will invoke the builder (currently [@nuxt/vite-builder](https://github.com/nuxt/nuxt/tree/main/packages/vite) or [@nuxt/webpack-builder](https://github.com/nuxt/nuxt/tree/main/packages/webpack)) to bundle the application.
35
35
 
36
36
  ### Type
37
37
 
@@ -63,7 +63,7 @@ function assertNuxtCompatibility (constraints: NuxtCompatibility, nuxt?: Nuxt):
63
63
 
64
64
  ### Parameters
65
65
 
66
- **`constraints`**: Version and builder constraints to check against. Refer to the [constraints table in `checkNuxtCompatibility`](#parameters) for details.
66
+ **`constraints`**: Version and builder constraints to check against. Refer to the [constraints table in `checkNuxtCompatibility`](/docs/3.x/api/kit/compatibility#parameters) for details.
67
67
 
68
68
  **`nuxt`**: Nuxt instance. If not provided, it will be retrieved from the context via `useNuxt()` call.
69
69
 
@@ -96,7 +96,7 @@ function hasNuxtCompatibility (constraints: NuxtCompatibility, nuxt?: Nuxt): Pro
96
96
 
97
97
  ### Parameters
98
98
 
99
- **`constraints`**: Version and builder constraints to check against. Refer to the [constraints table in `checkNuxtCompatibility`](#parameters) for details.
99
+ **`constraints`**: Version and builder constraints to check against. Refer to the [constraints table in `checkNuxtCompatibility`](/docs/3.x/api/kit/compatibility#parameters) for details.
100
100
 
101
101
  **`nuxt`**: Nuxt instance. If not provided, it will be retrieved from the context via `useNuxt()` call.
102
102
 
@@ -58,16 +58,16 @@ function addImports (imports: Import | Import[]): void
58
58
 
59
59
  `imports`: An object or an array of objects with the following properties:
60
60
 
61
- | Property | Type | Required | Description |
62
- | ------------------ | ---------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
63
- | `name` | `string` | `true` | Import name to be detected. |
64
- | `from` | `string` | `true` | Module specifier to import from. |
65
- | `priority` | `number` | `false` | Priority of the import; if multiple imports have the same name, the one with the highest priority will be used. |
66
- | `disabled` | `boolean` | `false` | If this import is disabled. |
67
- | `meta` | `Record<string, any>` | `false` | Metadata of the import. |
68
- | `type` | `boolean` | `false` | If this import is a pure type import. |
69
- | `typeFrom` | `string` | `false` | Use this as the `from` value when generating type declarations. |
70
- | `as` | `string` | `false` | Import as this name. |
61
+ | Property | Type | Required | Description |
62
+ |------------|-----------------------|----------|-----------------------------------------------------------------------------------------------------------------|
63
+ | `name` | `string` | `true` | Import name to be detected. |
64
+ | `from` | `string` | `true` | Module specifier to import from. |
65
+ | `priority` | `number` | `false` | Priority of the import; if multiple imports have the same name, the one with the highest priority will be used. |
66
+ | `disabled` | `boolean` | `false` | If this import is disabled. |
67
+ | `meta` | `Record<string, any>` | `false` | Metadata of the import. |
68
+ | `type` | `boolean` | `false` | If this import is a pure type import. |
69
+ | `typeFrom` | `string` | `false` | Use this as the `from` value when generating type declarations. |
70
+ | `as` | `string` | `false` | Import as this name. |
71
71
 
72
72
  ## `addImportsDir`
73
73
 
@@ -98,10 +98,10 @@ function addImportsDir (dirs: string | string[], options?: { prepend?: boolean }
98
98
 
99
99
  ### Parameters
100
100
 
101
- | Property | Type | Required | Description |
102
- | ------------------ | ---------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
103
- | `dirs` | `string \| string[]`{lang="ts"} | `true` | A string or an array of strings with the path to the directory to import from. |
104
- | `options` | `{ prepend?: boolean }`{lang="ts"} | `false` | Options to pass to the import. If `prepend` is set to `true`, the imports will be prepended to the list of imports. |
101
+ | Property | Type | Required | Description |
102
+ |-----------|------------------------------------|----------|---------------------------------------------------------------------------------------------------------------------|
103
+ | `dirs` | `string \| string[]`{lang="ts"} | `true` | A string or an array of strings with the path to the directory to import from. |
104
+ | `options` | `{ prepend?: boolean }`{lang="ts"} | `false` | Options to pass to the import. If `prepend` is set to `true`, the imports will be prepended to the list of imports. |
105
105
 
106
106
  ## `addImportsSources`
107
107
 
@@ -138,7 +138,7 @@ function addImportsSources (importSources: ImportSource | ImportSource[]): void
138
138
 
139
139
  **importSources**: An object or an array of objects with the following properties:
140
140
 
141
- | Property | Type | Required | Description |
142
- | ------------------ | ---------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
143
- | `from` | `string` | `true` | Module specifier to import from. |
144
- | `imports` | `PresetImport \| ImportSource[]`{lang="ts"} | `true` | An object or an array of objects, which can be import names, import objects or import sources. |
141
+ | Property | Type | Required | Description |
142
+ |-----------|---------------------------------------------|----------|------------------------------------------------------------------------------------------------|
143
+ | `from` | `string` | `true` | Module specifier to import from. |
144
+ | `imports` | `PresetImport \| ImportSource[]`{lang="ts"} | `true` | An object or an array of objects, which can be import names, import objects or import sources. |