@nuxt/docs 3.19.2 → 3.19.3

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 (191) hide show
  1. package/1.getting-started/01.introduction.md +2 -2
  2. package/1.getting-started/02.installation.md +1 -0
  3. package/1.getting-started/03.configuration.md +29 -29
  4. package/1.getting-started/04.views.md +7 -7
  5. package/1.getting-started/05.assets.md +15 -9
  6. package/1.getting-started/06.styling.md +55 -45
  7. package/1.getting-started/07.routing.md +12 -12
  8. package/1.getting-started/08.seo-meta.md +55 -42
  9. package/1.getting-started/09.transitions.md +47 -42
  10. package/1.getting-started/10.data-fetching.md +90 -67
  11. package/1.getting-started/11.state-management.md +22 -15
  12. package/1.getting-started/12.error-handling.md +11 -9
  13. package/1.getting-started/13.server.md +3 -3
  14. package/1.getting-started/14.layers.md +21 -15
  15. package/1.getting-started/15.prerendering.md +28 -28
  16. package/1.getting-started/16.deployment.md +9 -9
  17. package/1.getting-started/17.testing.md +43 -43
  18. package/1.getting-started/18.upgrade.md +58 -57
  19. package/2.guide/0.index.md +3 -3
  20. package/2.guide/{2.directory-structure → 1.directory-structure}/.navigation.yml +1 -1
  21. package/2.guide/{2.directory-structure → 1.directory-structure}/0.nuxt.md +3 -3
  22. package/2.guide/{2.directory-structure → 1.directory-structure}/0.output.md +3 -3
  23. package/2.guide/{2.directory-structure → 1.directory-structure}/1.assets.md +3 -3
  24. package/2.guide/{2.directory-structure → 1.directory-structure}/1.components.md +41 -24
  25. package/2.guide/{2.directory-structure → 1.directory-structure}/1.composables.md +11 -11
  26. package/2.guide/{2.directory-structure → 1.directory-structure}/1.content.md +7 -4
  27. package/2.guide/{2.directory-structure → 1.directory-structure}/1.layouts.md +16 -12
  28. package/2.guide/{2.directory-structure → 1.directory-structure}/1.middleware.md +28 -22
  29. package/2.guide/{2.directory-structure → 1.directory-structure}/1.modules.md +6 -6
  30. package/2.guide/{2.directory-structure → 1.directory-structure}/1.node_modules.md +2 -2
  31. package/2.guide/{2.directory-structure → 1.directory-structure}/1.pages.md +33 -31
  32. package/2.guide/{2.directory-structure → 1.directory-structure}/1.plugins.md +25 -25
  33. package/2.guide/{2.directory-structure → 1.directory-structure}/1.public.md +2 -2
  34. package/2.guide/{2.directory-structure → 1.directory-structure}/1.server.md +34 -34
  35. package/2.guide/{2.directory-structure → 1.directory-structure}/1.shared.md +6 -6
  36. package/2.guide/{2.directory-structure → 1.directory-structure}/1.utils.md +5 -5
  37. package/2.guide/{2.directory-structure → 1.directory-structure}/2.env.md +5 -5
  38. package/2.guide/{2.directory-structure → 1.directory-structure}/2.gitignore.md +1 -1
  39. package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtignore.md +4 -4
  40. package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtrc.md +3 -3
  41. package/2.guide/{2.directory-structure → 1.directory-structure}/3.app-config.md +12 -12
  42. package/2.guide/{2.directory-structure → 1.directory-structure}/3.app.md +4 -4
  43. package/2.guide/{2.directory-structure → 1.directory-structure}/3.error.md +6 -6
  44. package/2.guide/{2.directory-structure → 1.directory-structure}/3.nuxt-config.md +2 -2
  45. package/2.guide/{2.directory-structure → 1.directory-structure}/3.package.md +1 -1
  46. package/2.guide/{2.directory-structure → 1.directory-structure}/3.tsconfig.md +3 -3
  47. package/2.guide/{1.concepts → 2.concepts}/1.auto-imports.md +18 -18
  48. package/2.guide/{1.concepts → 2.concepts}/10.nuxt-lifecycle.md +10 -10
  49. package/2.guide/{1.concepts → 2.concepts}/2.vuejs-development.md +9 -9
  50. package/2.guide/{1.concepts → 2.concepts}/3.rendering.md +21 -19
  51. package/2.guide/{1.concepts → 2.concepts}/4.server-engine.md +5 -5
  52. package/2.guide/{1.concepts → 2.concepts}/5.modules.md +4 -4
  53. package/2.guide/{1.concepts → 2.concepts}/7.esm.md +15 -13
  54. package/2.guide/{1.concepts → 2.concepts}/8.typescript.md +11 -11
  55. package/2.guide/3.going-further/1.events.md +2 -2
  56. package/2.guide/3.going-further/1.experimental-features.md +80 -80
  57. package/2.guide/3.going-further/1.features.md +15 -15
  58. package/2.guide/3.going-further/1.internals.md +25 -25
  59. package/2.guide/3.going-further/10.runtime-config.md +11 -11
  60. package/2.guide/3.going-further/2.hooks.md +11 -11
  61. package/2.guide/3.going-further/3.modules.md +89 -87
  62. package/2.guide/3.going-further/4.kit.md +5 -5
  63. package/2.guide/3.going-further/6.nuxt-app.md +5 -5
  64. package/2.guide/3.going-further/7.layers.md +61 -52
  65. package/2.guide/3.going-further/9.debugging.md +2 -2
  66. package/2.guide/4.recipes/1.custom-routing.md +31 -31
  67. package/2.guide/4.recipes/2.vite-plugin.md +4 -4
  68. package/2.guide/4.recipes/3.custom-usefetch.md +12 -12
  69. package/2.guide/4.recipes/4.sessions-and-authentication.md +34 -20
  70. package/2.guide/5.best-practices/hydration.md +4 -4
  71. package/2.guide/5.best-practices/performance.md +12 -12
  72. package/3.api/1.components/1.client-only.md +6 -3
  73. package/3.api/1.components/1.nuxt-client-fallback.md +9 -6
  74. package/3.api/1.components/10.nuxt-picture.md +1 -1
  75. package/3.api/1.components/11.teleports.md +4 -1
  76. package/3.api/1.components/12.nuxt-route-announcer.md +9 -9
  77. package/3.api/1.components/13.nuxt-time.md +44 -17
  78. package/3.api/1.components/2.nuxt-page.md +4 -4
  79. package/3.api/1.components/3.nuxt-layout.md +11 -6
  80. package/3.api/1.components/4.nuxt-link.md +40 -20
  81. package/3.api/1.components/5.nuxt-loading-indicator.md +2 -2
  82. package/3.api/1.components/6.nuxt-error-boundary.md +11 -9
  83. package/3.api/2.composables/on-prehydrate.md +2 -2
  84. package/3.api/2.composables/use-async-data.md +17 -17
  85. package/3.api/2.composables/use-cookie.md +28 -20
  86. package/3.api/2.composables/use-error.md +1 -1
  87. package/3.api/2.composables/use-fetch.md +55 -29
  88. package/3.api/2.composables/use-head-safe.md +7 -7
  89. package/3.api/2.composables/use-head.md +4 -4
  90. package/3.api/2.composables/use-hydration.md +6 -6
  91. package/3.api/2.composables/use-lazy-async-data.md +2 -2
  92. package/3.api/2.composables/use-lazy-fetch.md +2 -2
  93. package/3.api/2.composables/use-loading-indicator.md +12 -12
  94. package/3.api/2.composables/use-nuxt-app.md +19 -19
  95. package/3.api/2.composables/use-nuxt-data.md +8 -8
  96. package/3.api/2.composables/use-preview-mode.md +15 -18
  97. package/3.api/2.composables/use-request-event.md +1 -1
  98. package/3.api/2.composables/use-request-fetch.md +3 -3
  99. package/3.api/2.composables/use-request-header.md +1 -1
  100. package/3.api/2.composables/use-request-headers.md +4 -4
  101. package/3.api/2.composables/use-request-url.md +1 -1
  102. package/3.api/2.composables/use-response-header.md +9 -10
  103. package/3.api/2.composables/use-route-announcer.md +4 -4
  104. package/3.api/2.composables/use-route.md +1 -1
  105. package/3.api/2.composables/use-router.md +9 -7
  106. package/3.api/2.composables/use-runtime-config.md +6 -6
  107. package/3.api/2.composables/use-runtime-hook.md +2 -2
  108. package/3.api/2.composables/use-seo-meta.md +2 -2
  109. package/3.api/2.composables/use-server-seo-meta.md +4 -4
  110. package/3.api/2.composables/use-state.md +4 -4
  111. package/3.api/3.utils/$fetch.md +9 -7
  112. package/3.api/3.utils/abort-navigation.md +3 -3
  113. package/3.api/3.utils/add-route-middleware.md +5 -5
  114. package/3.api/3.utils/call-once.md +4 -4
  115. package/3.api/3.utils/clear-error.md +2 -2
  116. package/3.api/3.utils/clear-nuxt-data.md +3 -3
  117. package/3.api/3.utils/clear-nuxt-state.md +3 -3
  118. package/3.api/3.utils/create-error.md +1 -1
  119. package/3.api/3.utils/define-lazy-hydration-component.md +13 -13
  120. package/3.api/3.utils/define-nuxt-component.md +5 -5
  121. package/3.api/3.utils/define-nuxt-plugin.md +12 -12
  122. package/3.api/3.utils/define-nuxt-route-middleware.md +5 -5
  123. package/3.api/3.utils/define-page-meta.md +21 -21
  124. package/3.api/3.utils/define-route-rules.md +5 -5
  125. package/3.api/3.utils/navigate-to.md +10 -10
  126. package/3.api/3.utils/prefetch-components.md +1 -1
  127. package/3.api/3.utils/preload-components.md +1 -1
  128. package/3.api/3.utils/prerender-routes.md +3 -3
  129. package/3.api/3.utils/refresh-cookie.md +3 -3
  130. package/3.api/3.utils/refresh-nuxt-data.md +11 -6
  131. package/3.api/3.utils/reload-nuxt-app.md +2 -2
  132. package/3.api/3.utils/set-page-layout.md +1 -1
  133. package/3.api/3.utils/set-response-status.md +2 -2
  134. package/3.api/3.utils/show-error.md +4 -4
  135. package/3.api/3.utils/update-app-config.md +3 -2
  136. package/3.api/4.commands/add.md +1 -1
  137. package/3.api/4.commands/analyze.md +2 -1
  138. package/3.api/4.commands/build.md +2 -1
  139. package/3.api/4.commands/dev.md +5 -4
  140. package/3.api/4.commands/generate.md +2 -1
  141. package/3.api/4.commands/init.md +3 -2
  142. package/3.api/4.commands/module.md +4 -4
  143. package/3.api/4.commands/prepare.md +7 -2
  144. package/3.api/4.commands/preview.md +5 -4
  145. package/3.api/4.commands/test.md +40 -0
  146. package/3.api/4.commands/typecheck.md +4 -2
  147. package/3.api/4.commands/upgrade.md +3 -3
  148. package/3.api/5.kit/1.modules.md +36 -36
  149. package/3.api/5.kit/10.runtime-config.md +1 -1
  150. package/3.api/5.kit/10.templates.md +8 -6
  151. package/3.api/5.kit/11.nitro.md +62 -62
  152. package/3.api/5.kit/12.resolving.md +2 -2
  153. package/3.api/5.kit/14.builder.md +1 -0
  154. package/3.api/5.kit/15.examples.md +2 -2
  155. package/3.api/5.kit/16.layers.md +26 -26
  156. package/3.api/5.kit/3.compatibility.md +12 -12
  157. package/3.api/5.kit/4.autoimports.md +13 -13
  158. package/3.api/5.kit/5.components.md +7 -7
  159. package/3.api/5.kit/6.context.md +3 -3
  160. package/3.api/5.kit/7.pages.md +7 -7
  161. package/3.api/5.kit/8.layout.md +2 -2
  162. package/3.api/5.kit/9.plugins.md +6 -5
  163. package/3.api/6.advanced/1.hooks.md +2 -2
  164. package/3.api/6.advanced/2.import-meta.md +3 -3
  165. package/5.community/2.getting-help.md +1 -1
  166. package/5.community/3.reporting-bugs.md +1 -1
  167. package/5.community/4.contribution.md +6 -6
  168. package/5.community/5.framework-contribution.md +3 -3
  169. package/5.community/6.roadmap.md +1 -1
  170. package/6.bridge/1.overview.md +13 -13
  171. package/6.bridge/10.configuration.md +2 -1
  172. package/6.bridge/2.typescript.md +2 -2
  173. package/6.bridge/3.bridge-composition-api.md +6 -6
  174. package/6.bridge/4.plugins-and-middleware.md +9 -9
  175. package/6.bridge/5.nuxt3-compatible-api.md +19 -16
  176. package/6.bridge/6.meta.md +20 -19
  177. package/6.bridge/7.runtime-config.md +1 -1
  178. package/6.bridge/8.nitro.md +3 -3
  179. package/6.bridge/9.vite.md +4 -4
  180. package/7.migration/1.overview.md +2 -2
  181. package/7.migration/2.configuration.md +22 -20
  182. package/7.migration/20.module-authors.md +6 -6
  183. package/7.migration/3.auto-imports.md +3 -3
  184. package/7.migration/4.meta.md +20 -17
  185. package/7.migration/5.plugins-and-middleware.md +5 -5
  186. package/7.migration/6.pages-and-layouts.md +23 -19
  187. package/7.migration/7.component-options.md +14 -14
  188. package/7.migration/8.runtime-config.md +6 -6
  189. package/package.json +1 -1
  190. /package/2.guide/{1.concepts → 2.concepts}/.navigation.yml +0 -0
  191. /package/2.guide/{1.concepts → 2.concepts}/9.code-style.md +0 -0
@@ -11,14 +11,14 @@ links:
11
11
  When prerendering, you can hint to Nitro to prerender additional paths, even if their URLs do not show up in the HTML of the generated page.
12
12
 
13
13
  ::important
14
- `prerenderRoutes` can only be called within the [Nuxt context](/docs/guide/going-further/nuxt-app#the-nuxt-context).
14
+ `prerenderRoutes` can only be called within the [Nuxt context](/docs/3.x/guide/going-further/nuxt-app#the-nuxt-context).
15
15
  ::
16
16
 
17
17
  ::note
18
18
  `prerenderRoutes` has to be executed during prerendering. If the `prerenderRoutes` is used in dynamic pages/routes which are not prerendered, then it will not be executed.
19
19
  ::
20
20
 
21
- ```js
21
+ ```ts
22
22
  const route = useRoute()
23
23
 
24
24
  prerenderRoutes('/')
@@ -31,7 +31,7 @@ In the browser, or if called outside prerendering, `prerenderRoutes` will have n
31
31
 
32
32
  You can even prerender API routes which is particularly useful for full statically generated sites (SSG) because you can then `$fetch` data as if you have an available server!
33
33
 
34
- ```js
34
+ ```ts
35
35
  prerenderRoutes('/api/content/article/name-of-article')
36
36
 
37
37
  // Somewhere later in App
@@ -27,7 +27,7 @@ This is useful for updating the `useCookie` ref when we know the new cookie valu
27
27
  const tokenCookie = useCookie('token')
28
28
 
29
29
  const login = async (username, password) => {
30
- const token = await $fetch('/api/token', { ... }) // Sets `token` cookie on response
30
+ const token = await $fetch('/api/token', { /** ... */ }) // Sets `token` cookie on response
31
31
  refreshCookie('token')
32
32
  }
33
33
 
@@ -41,6 +41,6 @@ You can enable experimental `cookieStore` option to automatically refresh `useCo
41
41
 
42
42
  ## Type
43
43
 
44
- ```ts
45
- refreshCookie(name: string): void
44
+ ```ts [Signature]
45
+ export function refreshCookie (name: string): void
46
46
  ```
@@ -8,7 +8,7 @@ links:
8
8
  size: xs
9
9
  ---
10
10
 
11
- `refreshNuxtData` is used to refetch all or specific `asyncData` instances, including those from [`useAsyncData`](/docs/api/composables/use-async-data), [`useLazyAsyncData`](/docs/api/composables/use-lazy-async-data), [`useFetch`](/docs/api/composables/use-fetch), and [`useLazyFetch`](/docs/api/composables/use-lazy-fetch).
11
+ `refreshNuxtData` is used to refetch all or specific `asyncData` instances, including those from [`useAsyncData`](/docs/3.x/api/composables/use-async-data), [`useLazyAsyncData`](/docs/3.x/api/composables/use-lazy-async-data), [`useFetch`](/docs/3.x/api/composables/use-fetch), and [`useLazyFetch`](/docs/3.x/api/composables/use-lazy-fetch).
12
12
 
13
13
  ::note
14
14
  If your component is cached by `<KeepAlive>` and enters a deactivated state, the `asyncData` inside the component will still be refetched until the component is unmounted.
@@ -16,13 +16,13 @@ If your component is cached by `<KeepAlive>` and enters a deactivated state, the
16
16
 
17
17
  ## Type
18
18
 
19
- ```ts
20
- refreshNuxtData(keys?: string | string[])
19
+ ```ts [Signature]
20
+ export function refreshNuxtData (keys?: string | string[])
21
21
  ```
22
22
 
23
23
  ## Parameters
24
24
 
25
- * `keys`: A single string or an array of strings as `keys` that are used to fetch the data. This parameter is **optional**. All [`useAsyncData`](/docs/api/composables/use-async-data) and [`useFetch`](/docs/api/composables/use-fetch) keys are re-fetched when no `keys` are explicitly specified.
25
+ * `keys`: A single string or an array of strings as `keys` that are used to fetch the data. This parameter is **optional**. All [`useAsyncData`](/docs/3.x/api/composables/use-async-data) and [`useFetch`](/docs/3.x/api/composables/use-fetch) keys are re-fetched when no `keys` are explicitly specified.
26
26
 
27
27
  ## Return Values
28
28
 
@@ -50,7 +50,10 @@ async function refreshAll () {
50
50
 
51
51
  <template>
52
52
  <div>
53
- <button :disabled="refreshing" @click="refreshAll">
53
+ <button
54
+ :disabled="refreshing"
55
+ @click="refreshAll"
56
+ >
54
57
  Refetch All Data
55
58
  </button>
56
59
  </div>
@@ -80,7 +83,9 @@ async function refresh () {
80
83
  <div v-if="refreshing">
81
84
  Loading
82
85
  </div>
83
- <button @click="refresh">Refresh</button>
86
+ <button @click="refresh">
87
+ Refresh
88
+ </button>
84
89
  </template>
85
90
  ```
86
91
 
@@ -20,8 +20,8 @@ You can enable experimental restoration of this state by enabling the `experimen
20
20
 
21
21
  ## Type
22
22
 
23
- ```ts
24
- reloadNuxtApp(options?: ReloadNuxtAppOptions)
23
+ ```ts [Signature]
24
+ export function reloadNuxtApp (options?: ReloadNuxtAppOptions)
25
25
 
26
26
  interface ReloadNuxtAppOptions {
27
27
  ttl?: number
@@ -9,7 +9,7 @@ links:
9
9
  ---
10
10
 
11
11
  ::important
12
- `setPageLayout` allows you to dynamically change the layout of a page. It relies on access to the Nuxt context and therefore can only be called within the [Nuxt context](/docs/guide/going-further/nuxt-app#the-nuxt-context).
12
+ `setPageLayout` allows you to dynamically change the layout of a page. It relies on access to the Nuxt context and therefore can only be called within the [Nuxt context](/docs/3.x/guide/going-further/nuxt-app#the-nuxt-context).
13
13
  ::
14
14
 
15
15
  ```ts [middleware/custom-layout.ts]
@@ -13,10 +13,10 @@ Nuxt provides composables and utilities for first-class server-side-rendering su
13
13
  `setResponseStatus` sets the statusCode (and optionally the statusMessage) of the response.
14
14
 
15
15
  ::important
16
- `setResponseStatus` can only be called in the [Nuxt context](/docs/guide/going-further/nuxt-app#the-nuxt-context).
16
+ `setResponseStatus` can only be called in the [Nuxt context](/docs/3.x/guide/going-further/nuxt-app#the-nuxt-context).
17
17
  ::
18
18
 
19
- ```js
19
+ ```ts
20
20
  const event = useRequestEvent()
21
21
 
22
22
  // event will be undefined in the browser
@@ -8,21 +8,21 @@ links:
8
8
  size: xs
9
9
  ---
10
10
 
11
- Within the [Nuxt context](/docs/guide/going-further/nuxt-app#the-nuxt-context) you can use `showError` to show an error.
11
+ Within the [Nuxt context](/docs/3.x/guide/going-further/nuxt-app#the-nuxt-context) you can use `showError` to show an error.
12
12
 
13
13
  **Parameters:**
14
14
 
15
15
  - `error`: `string | Error | Partial<{ cause, data, message, name, stack, statusCode, statusMessage }>`
16
16
 
17
17
  ```ts
18
- showError("😱 Oh no, an error has been thrown.")
18
+ showError('😱 Oh no, an error has been thrown.')
19
19
  showError({
20
20
  statusCode: 404,
21
- statusMessage: "Page Not Found"
21
+ statusMessage: 'Page Not Found',
22
22
  })
23
23
  ```
24
24
 
25
- The error is set in the state using [`useError()`](/docs/api/composables/use-error) to create a reactive and SSR-friendly shared error state across components.
25
+ The error is set in the state using [`useError()`](/docs/3.x/api/composables/use-error) to create a reactive and SSR-friendly shared error state across components.
26
26
 
27
27
  ::tip
28
28
  `showError` calls the `app:error` hook.
@@ -9,16 +9,17 @@ links:
9
9
  ---
10
10
 
11
11
  ::note
12
- Updates the [`app.config`](/docs/guide/directory-structure/app-config) using deep assignment. Existing (nested) properties will be preserved.
12
+ Updates the [`app.config`](/docs/3.x/guide/directory-structure/app-config) using deep assignment. Existing (nested) properties will be preserved.
13
13
  ::
14
14
 
15
15
  ## Usage
16
16
 
17
17
  ```js
18
+ import { updateAppConfig, useAppConfig } from '#imports'
19
+
18
20
  const appConfig = useAppConfig() // { foo: 'bar' }
19
21
 
20
22
  const newAppConfig = { foo: 'baz' }
21
-
22
23
  updateAppConfig(newAppConfig)
23
24
 
24
25
  console.log(appConfig) // { foo: 'baz' }
@@ -19,7 +19,7 @@ npx nuxt add <TEMPLATE> <NAME> [--cwd=<directory>] [--logLevel=<silent|info|verb
19
19
  <!--add-args-->
20
20
  Argument | Description
21
21
  --- | ---
22
- `TEMPLATE` | Specify which template to generate (options: <api\|plugin\|component\|composable\|middleware\|layout\|page\|layer>)
22
+ `TEMPLATE` | Specify which template to generate (options: <api\|app\|app-config\|component\|composable\|error\|layer\|layout\|middleware\|module\|page\|plugin\|server-middleware\|server-plugin\|server-route\|server-util>)
23
23
  `NAME` | Specify name of the generated file
24
24
  <!--/add-args-->
25
25
 
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--analyze-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxt analyze [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [--name=<name>] [--no-serve]
13
+ npx nuxt analyze [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [-e, --extends=<layer-name>] [--name=<name>] [--no-serve]
14
14
  ```
15
15
  <!--/analyze-cmd-->
16
16
 
@@ -32,6 +32,7 @@ Option | Default | Description
32
32
  `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
33
33
  `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
34
34
  `--dotenv` | | Path to `.env` file to load, relative to the root directory
35
+ `-e, --extends=<layer-name>` | | Extend from a Nuxt layer
35
36
  `--name=<name>` | `default` | Name of the analysis
36
37
  `--no-serve` | | Skip serving the analysis results
37
38
  <!--/analyze-opts-->
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--build-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxt build [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--prerender] [--preset] [--dotenv] [--envName]
13
+ npx nuxt build [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--prerender] [--preset] [--dotenv] [--envName] [-e, --extends=<layer-name>]
14
14
  ```
15
15
  <!--/build-cmd-->
16
16
 
@@ -35,6 +35,7 @@ Option | Default | Description
35
35
  `--preset` | | Nitro server preset
36
36
  `--dotenv` | | Path to `.env` file to load, relative to the root directory
37
37
  `--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
38
+ `-e, --extends=<layer-name>` | | Extend from a Nuxt layer
38
39
  <!--/build-opts-->
39
40
 
40
41
  ::note
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--dev-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxt dev [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [--envName] [--no-clear] [--no-fork] [-p, --port] [-h, --host] [--clipboard] [-o, --open] [--https] [--publicURL] [--qr] [--public] [--tunnel] [--sslCert] [--sslKey]
13
+ npx nuxt dev [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [--envName] [-e, --extends=<layer-name>] [--clear] [--no-f, --no-fork] [-p, --port] [-h, --host] [--clipboard] [-o, --open] [--https] [--publicURL] [--qr] [--public] [--tunnel] [--sslCert] [--sslKey]
14
14
  ```
15
15
  <!--/dev-cmd-->
16
16
 
@@ -33,10 +33,11 @@ Option | Default | Description
33
33
  `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
34
34
  `--dotenv` | | Path to `.env` file to load, relative to the root directory
35
35
  `--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
36
- `--no-clear` | | Disable clear console on restart
37
- `--no-fork` | | Disable forked mode
36
+ `-e, --extends=<layer-name>` | | Extend from a Nuxt layer
37
+ `--clear` | `false` | Clear console on restart
38
+ `--no-f, --no-fork` | | Disable forked mode
38
39
  `-p, --port` | | Port to listen on (default: `NUXT_PORT \|\| NITRO_PORT \|\| PORT \|\| nuxtOptions.devServer.port`)
39
- `-h, --host` | | Host to listen on (default: `NUXT_HOST \|\| NITRO_HOST \|\| HOST \|\| nuxtOptions._layers?.[0]?.devServer?.host`)
40
+ `-h, --host` | | Host to listen on (default: `NUXT_HOST \|\| NITRO_HOST \|\| HOST \|\| nuxtOptions.devServer?.host`)
40
41
  `--clipboard` | `false` | Copy the URL to the clipboard
41
42
  `-o, --open` | `false` | Open the URL in the browser
42
43
  `--https` | | Enable HTTPS
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--generate-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxt generate [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--preset] [--dotenv] [--envName]
13
+ npx nuxt generate [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--preset] [--dotenv] [--envName] [-e, --extends=<layer-name>]
14
14
  ```
15
15
  <!--/generate-cmd-->
16
16
 
@@ -34,6 +34,7 @@ Option | Default | Description
34
34
  `--preset` | | Nitro server preset
35
35
  `--dotenv` | | Path to `.env` file to load, relative to the root directory
36
36
  `--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
37
+ `-e, --extends=<layer-name>` | | Extend from a Nuxt layer
37
38
  <!--/generate-opts-->
38
39
 
39
40
  ::read-more{to="/docs/getting-started/deployment#static-hosting"}
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--init-cmd-->
12
12
  ```bash [Terminal]
13
- npm create nuxt@latest [DIR] [--cwd=<directory>] [-t, --template] [-f, --force] [--offline] [--preferOffline] [--no-install] [--gitInit] [--shell] [--packageManager] [--nightly]
13
+ npm create nuxt@latest [DIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [-t, --template] [-f, --force] [--offline] [--preferOffline] [--no-install] [--gitInit] [--shell] [--packageManager] [-M, --modules] [--no-modules] [--nightly]
14
14
  ```
15
15
  <!--/init-cmd-->
16
16
 
@@ -30,6 +30,7 @@ Argument | Description
30
30
  Option | Default | Description
31
31
  --- | --- | ---
32
32
  `--cwd=<directory>` | `.` | Specify the working directory
33
+ `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
33
34
  `-t, --template` | | Template name
34
35
  `-f, --force` | | Override existing directory
35
36
  `--offline` | | Force offline mode
@@ -38,7 +39,7 @@ Option | Default | Description
38
39
  `--gitInit` | | Initialize git repository
39
40
  `--shell` | | Start shell after installation in project directory
40
41
  `--packageManager` | | Package manager choice (npm, pnpm, yarn, bun)
41
- `--modules` | | Nuxt modules to install (comma separated without spaces)
42
+ `-M, --modules` | | Nuxt modules to install (comma separated without spaces)
42
43
  `--no-modules` | | Skip module installation prompt
43
44
  `--nightly` | | Use Nuxt nightly release channel (3x or latest)
44
45
  <!--/init-opts-->
@@ -21,7 +21,7 @@ npx nuxt module add <MODULENAME> [--cwd=<directory>] [--logLevel=<silent|info|ve
21
21
  <!--module-add-args-->
22
22
  Argument | Description
23
23
  --- | ---
24
- `MODULENAME` | Module name
24
+ `MODULENAME` | Specify one or more modules to install by name, separated by spaces
25
25
  <!--/module-add-args-->
26
26
 
27
27
  <!--module-add-opts-->
@@ -31,7 +31,7 @@ Option | Default | Description
31
31
  `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
32
32
  `--skipInstall` | | Skip npm install
33
33
  `--skipConfig` | | Skip nuxt.config.ts update
34
- `--dev` | | Install module as dev dependency
34
+ `--dev` | | Install modules as dev dependencies
35
35
  <!--/module-add-opts-->
36
36
 
37
37
  The command lets you install [Nuxt modules](/modules) in your application with no manual work.
@@ -39,8 +39,8 @@ The command lets you install [Nuxt modules](/modules) in your application with n
39
39
  When running the command, it will:
40
40
 
41
41
  - install the module as a dependency using your package manager
42
- - add it to your [package.json](/docs/guide/directory-structure/package) file
43
- - update your [`nuxt.config`](/docs/guide/directory-structure/nuxt-config) file
42
+ - add it to your [package.json](/docs/3.x/guide/directory-structure/package) file
43
+ - update your [`nuxt.config`](/docs/3.x/guide/directory-structure/nuxt-config) file
44
44
 
45
45
  **Example:**
46
46
 
@@ -10,11 +10,11 @@ links:
10
10
 
11
11
  <!--prepare-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxt prepare [ROOTDIR] [--dotenv] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--envName]
13
+ npx nuxt prepare [ROOTDIR] [--dotenv] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--envName] [-e, --extends=<layer-name>]
14
14
  ```
15
15
  <!--/prepare-cmd-->
16
16
 
17
- The `prepare` command creates a [`.nuxt`](/docs/guide/directory-structure/nuxt) directory in your application and generates types. This can be useful in a CI environment or as a `postinstall` command in your [`package.json`](/docs/guide/directory-structure/package).
17
+ The `prepare` command creates a [`.nuxt`](/docs/3.x/guide/directory-structure/nuxt) directory in your application and generates types. This can be useful in a CI environment or as a `postinstall` command in your [`package.json`](/docs/3.x/guide/directory-structure/package).
18
18
 
19
19
  ## Arguments
20
20
 
@@ -33,4 +33,9 @@ Option | Default | Description
33
33
  `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
34
34
  `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
35
35
  `--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
36
+ `-e, --extends=<layer-name>` | | Extend from a Nuxt layer
36
37
  <!--/prepare-opts-->
38
+
39
+ ::note
40
+ This command sets `process.env.NODE_ENV` to `production`.
41
+ ::
@@ -10,11 +10,11 @@ links:
10
10
 
11
11
  <!--preview-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxt preview [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--envName] [--dotenv] [-p, --port]
13
+ npx nuxt preview [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--envName] [-e, --extends=<layer-name>] [-p, --port] [--dotenv]
14
14
  ```
15
15
  <!--/preview-cmd-->
16
16
 
17
- The `preview` command starts a server to preview your Nuxt application after running the `build` command. The `start` command is an alias for `preview`. When running your application in production refer to the [Deployment section](/docs/getting-started/deployment).
17
+ The `preview` command starts a server to preview your Nuxt application after running the `build` command. The `start` command is an alias for `preview`. When running your application in production refer to the [Deployment section](/docs/3.x/getting-started/deployment).
18
18
 
19
19
  ## Arguments
20
20
 
@@ -32,12 +32,13 @@ Option | Default | Description
32
32
  `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
33
33
  `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
34
34
  `--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
35
+ `-e, --extends=<layer-name>` | | Extend from a Nuxt layer
36
+ `-p, --port` | | Port to listen on (use `PORT` environment variable to override)
35
37
  `--dotenv` | | Path to `.env` file to load, relative to the root directory
36
- `-p, --port` | | Port to listen on (default: `NUXT_PORT \|\| NITRO_PORT \|\| PORT`)
37
38
  <!--/preview-opts-->
38
39
 
39
40
  This command sets `process.env.NODE_ENV` to `production`. To override, define `NODE_ENV` in a `.env` file or as command-line argument.
40
41
 
41
42
  ::note
42
- For convenience, in preview mode, your [`.env`](/docs/guide/directory-structure/env) file will be loaded into `process.env`. (However, in production you will need to ensure your environment variables are set yourself. For example, with Node.js 20+ you could do this by running `node --env-file .env .output/server/index.mjs` to start your server.)
43
+ For convenience, in preview mode, your [`.env`](/docs/3.x/guide/directory-structure/env) file will be loaded into `process.env`. (However, in production you will need to ensure your environment variables are set yourself. For example, with Node.js 20+ you could do this by running `node --env-file .env .output/server/index.mjs` to start your server.)
43
44
  ::
@@ -0,0 +1,40 @@
1
+ ---
2
+ title: "nuxt test"
3
+ description: The test command runs tests using @nuxt/test-utils.
4
+ links:
5
+ - label: Source
6
+ icon: i-simple-icons-github
7
+ to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/test.ts
8
+ size: xs
9
+ ---
10
+
11
+ <!--test-cmd-->
12
+ ```bash [Terminal]
13
+ npx nuxt test [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dev] [--watch]
14
+ ```
15
+ <!--/test-cmd-->
16
+
17
+ The `test` command runs tests using [`@nuxt/test-utils`](/docs/getting-started/testing). This command sets `process.env.NODE_ENV` to `test` if not already set.
18
+
19
+ ## Arguments
20
+
21
+ <!--test-args-->
22
+ Argument | Description
23
+ --- | ---
24
+ `ROOTDIR="."` | Specifies the working directory (default: `.`)
25
+ <!--/test-args-->
26
+
27
+ ## Options
28
+
29
+ <!--test-opts-->
30
+ Option | Default | Description
31
+ --- | --- | ---
32
+ `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
33
+ `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
34
+ `--dev` | | Run in dev mode
35
+ `--watch` | | Watch mode
36
+ <!--/test-opts-->
37
+
38
+ ::note
39
+ This command sets `process.env.NODE_ENV` to `test`.
40
+ ::
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--typecheck-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxt typecheck [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>]
13
+ npx nuxt typecheck [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [-e, --extends=<layer-name>]
14
14
  ```
15
15
  <!--/typecheck-cmd-->
16
16
 
@@ -31,10 +31,12 @@ Option | Default | Description
31
31
  --- | --- | ---
32
32
  `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
33
33
  `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
34
+ `--dotenv` | | Path to `.env` file to load, relative to the root directory
35
+ `-e, --extends=<layer-name>` | | Extend from a Nuxt layer
34
36
  <!--/typecheck-opts-->
35
37
 
36
38
  ::note
37
- This command sets `process.env.NODE_ENV` to `production`. To override, define `NODE_ENV` in a [`.env`](/docs/guide/directory-structure/env) file or as a command-line argument.
39
+ This command sets `process.env.NODE_ENV` to `production`. To override, define `NODE_ENV` in a [`.env`](/docs/3.x/guide/directory-structure/env) file or as a command-line argument.
38
40
  ::
39
41
 
40
42
  ::read-more{to="/docs/guide/concepts/typescript#type-checking"}
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--upgrade-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxt upgrade [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dedupe] [-f, --force] [-ch, --channel=<stable|nightly>]
13
+ npx nuxt upgrade [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dedupe] [-f, --force] [-ch, --channel=<stable|nightly|v3|v4|v4-nightly|v3-nightly>]
14
14
  ```
15
15
  <!--/upgrade-cmd-->
16
16
 
@@ -31,7 +31,7 @@ Option | Default | Description
31
31
  --- | --- | ---
32
32
  `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
33
33
  `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
34
- `--dedupe` | | Will deduplicate dependencies but not recreate the lockfile
34
+ `--dedupe` | | Dedupe dependencies after upgrading
35
35
  `-f, --force` | | Force upgrade to recreate lockfile and node_modules
36
- `-ch, --channel=<stable\|nightly>` | `stable` | Specify a channel to install from (default: stable)
36
+ `-ch, --channel=<stable\|nightly\|v3\|v4\|v4-nightly\|v3-nightly>` | `stable` | Specify a channel to install from (default: stable)
37
37
  <!--/upgrade-opts-->
@@ -22,16 +22,16 @@ import { defineNuxtModule } from '@nuxt/kit'
22
22
  export default defineNuxtModule({
23
23
  meta: {
24
24
  name: 'my-module',
25
- configKey: 'myModule'
25
+ configKey: 'myModule',
26
26
  },
27
27
  defaults: {
28
- enabled: true
28
+ enabled: true,
29
29
  },
30
30
  setup (options) {
31
31
  if (options.enabled) {
32
32
  console.log('My Nuxt module is enabled!')
33
33
  }
34
- }
34
+ },
35
35
  })
36
36
  ```
37
37
 
@@ -78,17 +78,17 @@ import { defineNuxtModule } from '@nuxt/kit'
78
78
  export default defineNuxtModule({
79
79
  meta: {
80
80
  name: 'my-module',
81
- configKey: 'myModule'
81
+ configKey: 'myModule',
82
82
  },
83
83
  defaults: {
84
84
  // Module options
85
- enabled: true
85
+ enabled: true,
86
86
  },
87
87
  setup (options) {
88
88
  if (options.enabled) {
89
89
  console.log('My Nuxt module is enabled!')
90
90
  }
91
- }
91
+ },
92
92
  })
93
93
  ```
94
94
 
@@ -97,8 +97,8 @@ Users can provide options for this module under the corresponding key in `nuxt.c
97
97
  ```ts
98
98
  export default defineNuxtConfig({
99
99
  myModule: {
100
- enabled: false
101
- }
100
+ enabled: false,
101
+ },
102
102
  })
103
103
  ```
104
104
 
@@ -116,7 +116,7 @@ export default defineNuxtModule({
116
116
  nuxt: '>=3.0.0', // or use '^3.0.0'
117
117
  },
118
118
  },
119
- async setup() {
119
+ setup () {
120
120
  const resolver = createResolver(import.meta.url)
121
121
  // Implement
122
122
  },
@@ -148,26 +148,26 @@ interface ModuleOptions {
148
148
  export default defineNuxtModule<ModuleOptions>().with({
149
149
  meta: {
150
150
  name: '@nuxtjs/my-api',
151
- configKey: 'myApi'
151
+ configKey: 'myApi',
152
152
  },
153
153
  defaults: {
154
154
  baseURL: 'https://api.example.com',
155
155
  timeout: 5000,
156
- retries: 3
156
+ retries: 3,
157
157
  },
158
- setup(resolvedOptions, nuxt) {
158
+ setup (resolvedOptions, nuxt) {
159
159
  // resolvedOptions is properly typed as:
160
160
  // {
161
161
  // apiKey: string // Required, no default provided
162
162
  // baseURL: string // Required, has default value
163
163
  // timeout: number // Optional, has default value
164
- // retries: number // Optional, has default value
164
+ // retries: number // Optional, has default value
165
165
  // }
166
-
166
+
167
167
  console.log(resolvedOptions.baseURL) // ✅ TypeScript knows this is always defined
168
168
  console.log(resolvedOptions.timeout) // ✅ TypeScript knows this is always defined
169
169
  console.log(resolvedOptions.retries) // ✅ TypeScript knows this is always defined
170
- }
170
+ },
171
171
  })
172
172
  ```
173
173
 
@@ -197,45 +197,45 @@ export default defineNuxtModule({
197
197
  meta: {
198
198
  name: 'my-awesome-module',
199
199
  version: '1.2.0', // Required for lifecycle hooks
200
- configKey: 'myAwesomeModule'
200
+ configKey: 'myAwesomeModule',
201
201
  },
202
202
  defaults: {
203
203
  apiKey: '',
204
- enabled: true
204
+ enabled: true,
205
205
  },
206
-
207
- onInstall(nuxt) {
206
+
207
+ onInstall (nuxt) {
208
208
  // This runs only when the module is first installed
209
209
  console.log('Setting up my-awesome-module for the first time!')
210
-
210
+
211
211
  // You might want to:
212
212
  // - Create initial configuration files
213
213
  // - Set up database schemas
214
214
  // - Display welcome messages
215
215
  // - Perform initial data migration
216
216
  },
217
-
218
- onUpgrade(options, nuxt, previousVersion) {
217
+
218
+ onUpgrade (options, nuxt, previousVersion) {
219
219
  // This runs when the module is upgraded to a newer version
220
220
  console.log(`Upgrading my-awesome-module from ${previousVersion} to 1.2.0`)
221
-
221
+
222
222
  // You might want to:
223
223
  // - Migrate configuration files
224
- // - Update database schemas
224
+ // - Update database schemas
225
225
  // - Clean up deprecated files
226
226
  // - Display upgrade notes
227
-
227
+
228
228
  if (semver.lt(previousVersion, '1.1.0')) {
229
229
  console.log('⚠️ Breaking changes in 1.1.0 - please check the migration guide')
230
230
  }
231
231
  },
232
-
233
- setup(options, nuxt) {
232
+
233
+ setup (options, nuxt) {
234
234
  // Regular setup logic runs on every build
235
235
  if (options.enabled) {
236
236
  // Configure the module
237
237
  }
238
- }
238
+ },
239
239
  })
240
240
  ```
241
241
 
@@ -248,7 +248,7 @@ Install specified Nuxt module programmatically. This is helpful when your module
248
248
  ```ts twoslash
249
249
  import { defineNuxtModule, installModule } from '@nuxt/kit'
250
250
 
251
- export default defineNuxtModule({
251
+ export default defineNuxtModule({
252
252
  async setup () {
253
253
  // will install @nuxtjs/fontaine with Roboto font and Impact fallback
254
254
  await installModule('@nuxtjs/fontaine', {
@@ -258,10 +258,10 @@ export default defineNuxtModule({
258
258
  family: 'Roboto',
259
259
  fallbacks: ['Impact'],
260
260
  fallbackName: 'fallback-a',
261
- }
262
- ]
261
+ },
262
+ ],
263
263
  })
264
- }
264
+ },
265
265
  })
266
266
  ```
267
267
 
@@ -284,7 +284,7 @@ async function installModule (moduleToInstall: string | NuxtModule, inlineOption
284
284
  ```ts
285
285
  import { defineNuxtModule, installModule } from '@nuxt/kit'
286
286
 
287
- export default defineNuxtModule({
287
+ export default defineNuxtModule({
288
288
  async setup (options, nuxt) {
289
289
  // will install @nuxtjs/fontaine with Roboto font and Impact fallback
290
290
  await installModule('@nuxtjs/fontaine', {
@@ -294,9 +294,9 @@ export default defineNuxtModule({
294
294
  family: 'Roboto',
295
295
  fallbacks: ['Impact'],
296
296
  fallbackName: 'fallback-a',
297
- }
298
- ]
297
+ },
298
+ ],
299
299
  })
300
- }
300
+ },
301
301
  })
302
302
  ```