@nuxt/docs-nightly 4.5.1-29752449.30d24817 → 4.5.2-2610052030-052d82e

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 (214) hide show
  1. package/1.getting-started/01.introduction.md +8 -8
  2. package/1.getting-started/02.installation.md +2 -4
  3. package/1.getting-started/03.configuration.md +16 -16
  4. package/1.getting-started/04.views.md +8 -8
  5. package/1.getting-started/05.assets.md +10 -10
  6. package/1.getting-started/06.styling.md +10 -10
  7. package/1.getting-started/07.routing.md +15 -15
  8. package/1.getting-started/08.seo-meta.md +15 -15
  9. package/1.getting-started/09.transitions.md +10 -10
  10. package/1.getting-started/10.data-fetching.md +61 -47
  11. package/1.getting-started/11.state-management.md +11 -11
  12. package/1.getting-started/12.error-handling.md +20 -18
  13. package/1.getting-started/13.server.md +7 -7
  14. package/1.getting-started/14.layers.md +6 -6
  15. package/1.getting-started/15.prerendering.md +22 -28
  16. package/1.getting-started/16.deployment.md +22 -6
  17. package/1.getting-started/17.testing.md +200 -21
  18. package/1.getting-started/18.upgrade.md +78 -278
  19. package/2.directory-structure/0.nuxt.md +2 -2
  20. package/2.directory-structure/0.output.md +3 -3
  21. package/2.directory-structure/1.app/1.assets.md +3 -3
  22. package/2.directory-structure/1.app/1.components.md +26 -109
  23. package/2.directory-structure/1.app/1.composables.md +5 -5
  24. package/2.directory-structure/1.app/1.layouts.md +10 -10
  25. package/2.directory-structure/1.app/1.middleware.md +14 -10
  26. package/2.directory-structure/1.app/1.pages.md +25 -20
  27. package/2.directory-structure/1.app/1.plugins.md +7 -7
  28. package/2.directory-structure/1.app/1.utils.md +9 -5
  29. package/2.directory-structure/1.app/3.app-config.md +7 -7
  30. package/2.directory-structure/1.app/3.app.md +6 -6
  31. package/2.directory-structure/1.app/3.error.md +1 -1
  32. package/2.directory-structure/1.content.md +1 -1
  33. package/2.directory-structure/1.layers.md +13 -13
  34. package/2.directory-structure/1.modules.md +3 -3
  35. package/2.directory-structure/1.node_modules.md +1 -1
  36. package/2.directory-structure/1.server.md +33 -14
  37. package/2.directory-structure/1.shared.md +7 -5
  38. package/2.directory-structure/1.test.md +25 -0
  39. package/2.directory-structure/2.env.md +7 -7
  40. package/2.directory-structure/2.nuxtignore.md +3 -3
  41. package/2.directory-structure/2.nuxtrc.md +3 -3
  42. package/2.directory-structure/3.nuxt-config.md +2 -2
  43. package/2.directory-structure/3.tsconfig.md +21 -11
  44. package/2.directory-structure/index.md +29 -25
  45. package/3.guide/0.index.md +6 -6
  46. package/3.guide/1.concepts/1.rendering.md +76 -12
  47. package/3.guide/1.concepts/10.vuejs-development.md +73 -8
  48. package/3.guide/1.concepts/2.nuxt-lifecycle.md +18 -18
  49. package/3.guide/1.concepts/3.auto-imports.md +11 -11
  50. package/3.guide/1.concepts/4.server-engine.md +6 -6
  51. package/3.guide/1.concepts/5.modules.md +4 -4
  52. package/3.guide/1.concepts/6.server-components.md +198 -0
  53. package/3.guide/1.concepts/7.esm.md +5 -5
  54. package/3.guide/1.concepts/8.typescript.md +9 -9
  55. package/3.guide/2.best-practices/accessibility.md +155 -0
  56. package/3.guide/2.best-practices/hydration.md +5 -5
  57. package/3.guide/2.best-practices/performance.md +13 -9
  58. package/3.guide/3.ai/1.mcp.md +104 -19
  59. package/3.guide/4.modules/2.module-anatomy.md +5 -5
  60. package/3.guide/4.modules/3.recipes-basics.md +8 -8
  61. package/3.guide/4.modules/4.module-dependencies.md +1 -1
  62. package/3.guide/4.modules/5.recipes-advanced.md +6 -8
  63. package/3.guide/4.modules/6.testing.md +2 -2
  64. package/3.guide/4.modules/7.best-practices.md +2 -2
  65. package/3.guide/4.modules/9.server-compatibility.md +215 -0
  66. package/3.guide/4.modules/index.md +9 -9
  67. package/3.guide/5.recipes/1.custom-routing.md +15 -11
  68. package/3.guide/5.recipes/2.vite-plugin.md +3 -3
  69. package/3.guide/5.recipes/3.custom-usefetch.md +5 -5
  70. package/3.guide/5.recipes/4.sessions-and-authentication.md +2 -2
  71. package/3.guide/5.recipes/5.mostly-static-sites.md +127 -0
  72. package/3.guide/6.going-further/1.events.md +1 -1
  73. package/3.guide/6.going-further/1.experimental-features.md +254 -22
  74. package/3.guide/6.going-further/1.features.md +42 -6
  75. package/3.guide/6.going-further/1.internals.md +10 -10
  76. package/3.guide/6.going-further/10.runtime-config.md +28 -6
  77. package/3.guide/6.going-further/11.nightly-release-channel.md +1 -1
  78. package/3.guide/6.going-further/2.hooks.md +6 -6
  79. package/3.guide/6.going-further/4.kit.md +4 -4
  80. package/3.guide/6.going-further/5.server-imports.md +221 -0
  81. package/3.guide/6.going-further/6.nuxt-app.md +7 -7
  82. package/3.guide/6.going-further/7.layers.md +13 -13
  83. package/3.guide/6.going-further/8.builders.md +38 -14
  84. package/4.api/1.components/1.nuxt-client-fallback.md +1 -1
  85. package/4.api/1.components/10.nuxt-picture.md +1 -1
  86. package/4.api/1.components/11.teleports.md +1 -1
  87. package/4.api/1.components/12.nuxt-route-announcer.md +5 -3
  88. package/4.api/1.components/14.nuxt-announcer.md +3 -3
  89. package/4.api/1.components/2.nuxt-page.md +5 -5
  90. package/4.api/1.components/3.nuxt-layout.md +8 -8
  91. package/4.api/1.components/4.nuxt-link.md +6 -4
  92. package/4.api/1.components/5.nuxt-loading-indicator.md +3 -3
  93. package/4.api/1.components/6.nuxt-error-boundary.md +1 -1
  94. package/4.api/1.components/8.nuxt-island.md +5 -5
  95. package/4.api/2.composables/create-use-async-data.md +51 -8
  96. package/4.api/2.composables/create-use-fetch.md +126 -9
  97. package/4.api/2.composables/use-announcer.md +3 -3
  98. package/4.api/2.composables/use-app-config.md +1 -1
  99. package/4.api/2.composables/use-async-data.md +19 -11
  100. package/4.api/2.composables/use-cookie.md +22 -6
  101. package/4.api/2.composables/use-error.md +1 -1
  102. package/4.api/2.composables/use-fetch.md +14 -10
  103. package/4.api/2.composables/use-head-safe.md +2 -2
  104. package/4.api/2.composables/use-head.md +2 -2
  105. package/4.api/2.composables/use-hydration.md +1 -1
  106. package/4.api/2.composables/use-layout.md +1 -1
  107. package/4.api/2.composables/use-lazy-async-data.md +8 -8
  108. package/4.api/2.composables/use-lazy-fetch.md +11 -11
  109. package/4.api/2.composables/use-loading-indicator.md +2 -2
  110. package/4.api/2.composables/use-nuxt-app.md +13 -13
  111. package/4.api/2.composables/use-nuxt-data.md +1 -1
  112. package/4.api/2.composables/use-preview-mode.md +3 -3
  113. package/4.api/2.composables/use-request-event.md +29 -3
  114. package/4.api/2.composables/use-request-fetch.md +2 -2
  115. package/4.api/2.composables/use-request-header.md +1 -1
  116. package/4.api/2.composables/use-request-headers.md +1 -1
  117. package/4.api/2.composables/use-request-url.md +1 -1
  118. package/4.api/2.composables/use-response-header.md +2 -2
  119. package/4.api/2.composables/use-route-announcer.md +4 -2
  120. package/4.api/2.composables/use-route.md +2 -2
  121. package/4.api/2.composables/use-router.md +5 -5
  122. package/4.api/2.composables/use-runtime-config.md +5 -5
  123. package/4.api/2.composables/use-runtime-hook.md +1 -1
  124. package/4.api/2.composables/use-seo-meta.md +3 -3
  125. package/4.api/2.composables/use-server-seo-meta.md +5 -5
  126. package/4.api/2.composables/use-state.md +4 -4
  127. package/4.api/3.utils/$fetch.md +5 -5
  128. package/4.api/3.utils/abort-navigation.md +1 -1
  129. package/4.api/3.utils/add-route-middleware.md +2 -2
  130. package/4.api/3.utils/call-once.md +3 -3
  131. package/4.api/3.utils/clear-error.md +2 -2
  132. package/4.api/3.utils/clear-nuxt-data.md +1 -1
  133. package/4.api/3.utils/clear-nuxt-state.md +2 -2
  134. package/4.api/3.utils/create-error.md +19 -1
  135. package/4.api/3.utils/define-nuxt-plugin.md +2 -2
  136. package/4.api/3.utils/define-nuxt-route-middleware.md +3 -3
  137. package/4.api/3.utils/define-page-meta.md +12 -12
  138. package/4.api/3.utils/define-route-rules.md +4 -4
  139. package/4.api/3.utils/define-use-async-data-addon.md +57 -0
  140. package/4.api/3.utils/define-use-fetch-addon.md +168 -0
  141. package/4.api/3.utils/navigate-to.md +6 -2
  142. package/4.api/3.utils/prefetch-components.md +1 -1
  143. package/4.api/3.utils/preload-route-components.md +2 -2
  144. package/4.api/3.utils/prerender-routes.md +3 -3
  145. package/4.api/3.utils/refresh-cookie.md +1 -1
  146. package/4.api/3.utils/refresh-nuxt-data.md +3 -3
  147. package/4.api/3.utils/reload-nuxt-app.md +1 -1
  148. package/4.api/3.utils/set-page-layout.md +1 -1
  149. package/4.api/3.utils/set-response-status.md +2 -2
  150. package/4.api/3.utils/show-error.md +3 -3
  151. package/4.api/3.utils/update-app-config.md +2 -2
  152. package/4.api/4.commands/README.md +9 -0
  153. package/4.api/5.kit/1.modules.md +3 -3
  154. package/4.api/5.kit/10.runtime-config.md +1 -1
  155. package/4.api/5.kit/10.templates.md +42 -0
  156. package/4.api/5.kit/12.nitro.md +59 -18
  157. package/4.api/5.kit/14.logging.md +56 -2
  158. package/4.api/5.kit/15.builder.md +1 -1
  159. package/4.api/5.kit/18.dependencies.md +90 -0
  160. package/4.api/5.kit/2.programmatic.md +78 -1
  161. package/4.api/5.kit/3.compatibility.md +2 -2
  162. package/4.api/5.kit/4.autoimports.md +13 -13
  163. package/4.api/5.kit/5.components.md +3 -3
  164. package/4.api/5.kit/6.context.md +2 -2
  165. package/4.api/5.kit/7.pages.md +35 -4
  166. package/4.api/5.kit/8.layout.md +1 -1
  167. package/4.api/6.advanced/1.hooks.md +6 -3
  168. package/4.api/6.nuxt-config.md +44 -21
  169. package/4.api/index.md +7 -7
  170. package/5.community/2.getting-help.md +1 -1
  171. package/5.community/3.reporting-bugs.md +1 -1
  172. package/5.community/4.contribution.md +14 -12
  173. package/5.community/5.framework-contribution.md +4 -4
  174. package/5.community/6.roadmap.md +6 -6
  175. package/6.bridge/1.overview.md +12 -12
  176. package/6.bridge/2.typescript.md +1 -1
  177. package/6.bridge/3.bridge-composition-api.md +6 -6
  178. package/6.bridge/4.plugins-and-middleware.md +4 -4
  179. package/6.bridge/5.nuxt3-compatible-api.md +9 -9
  180. package/6.bridge/6.meta.md +5 -5
  181. package/6.bridge/7.runtime-config.md +1 -1
  182. package/6.bridge/8.nitro.md +1 -1
  183. package/6.bridge/9.vite.md +1 -1
  184. package/7.migration/1.overview.md +2 -2
  185. package/7.migration/10.bundling.md +1 -1
  186. package/7.migration/11.server.md +3 -3
  187. package/7.migration/2.configuration.md +6 -6
  188. package/7.migration/20.module-authors.md +7 -7
  189. package/7.migration/3.auto-imports.md +3 -3
  190. package/7.migration/4.meta.md +4 -4
  191. package/7.migration/5.plugins-and-middleware.md +3 -3
  192. package/7.migration/6.pages-and-layouts.md +13 -13
  193. package/7.migration/7.component-options.md +15 -15
  194. package/7.migration/8.runtime-config.md +4 -4
  195. package/README.md +1 -1
  196. package/errors/e8007.md +28 -0
  197. package/package.json +2 -2
  198. package/4.api/4.commands/.navigation.yml +0 -3
  199. package/4.api/4.commands/add.md +0 -112
  200. package/4.api/4.commands/analyze.md +0 -42
  201. package/4.api/4.commands/build-module.md +0 -42
  202. package/4.api/4.commands/build.md +0 -48
  203. package/4.api/4.commands/cleanup.md +0 -38
  204. package/4.api/4.commands/dev.md +0 -61
  205. package/4.api/4.commands/devtools.md +0 -38
  206. package/4.api/4.commands/generate.md +0 -43
  207. package/4.api/4.commands/info.md +0 -33
  208. package/4.api/4.commands/init.md +0 -50
  209. package/4.api/4.commands/module.md +0 -84
  210. package/4.api/4.commands/prepare.md +0 -41
  211. package/4.api/4.commands/preview.md +0 -44
  212. package/4.api/4.commands/test.md +0 -40
  213. package/4.api/4.commands/typecheck.md +0 -44
  214. package/4.api/4.commands/upgrade.md +0 -37
@@ -5,7 +5,7 @@ description: Use the utils/ directory to auto-import your utility functions thro
5
5
  navigation.icon: i-vscode-icons-folder-type-tools
6
6
  ---
7
7
 
8
- The main purpose of the [`app/utils/` directory](/docs/4.x/directory-structure/app/utils) is to allow a semantic distinction between your Vue composables and other auto-imported utility functions.
8
+ The main purpose of the [`app/utils/` directory](/docs/directory-structure/app/utils) is to allow a semantic distinction between your Vue composables and other auto-imported utility functions.
9
9
 
10
10
  ## Usage
11
11
 
@@ -35,15 +35,19 @@ You can now use auto imported utility functions in `.js`, `.ts` and `.vue` files
35
35
  </template>
36
36
  ```
37
37
 
38
- :read-more{to="/docs/4.x/guide/concepts/auto-imports"}
38
+ :read-more{to="/docs/guide/concepts/auto-imports"}
39
39
 
40
- :link-example{to="/docs/4.x/examples/features/auto-imports"}
40
+ :link-example{to="/docs/examples/features/auto-imports"}
41
41
 
42
42
  ::tip
43
- The way `app/utils/` auto-imports work and are scanned is identical to the [`app/composables/`](/docs/4.x/directory-structure/app/composables) directory.
43
+ The way `app/utils/` auto-imports work and are scanned is identical to the [`app/composables/`](/docs/directory-structure/app/composables) directory.
44
44
  ::
45
45
 
46
46
  ::important
47
47
  These utils are only available within the Vue part of your app. :br
48
- Only `server/utils` are auto-imported in the [`server/`](/docs/4.x/directory-structure/server#server-utilities) directory.
48
+ Only `server/utils` are auto-imported in the [`server/`](/docs/directory-structure/server#server-utilities) directory.
49
+ ::
50
+
51
+ ::tip
52
+ Types can be auto-imported the same way. Put app-only types in `app/types/`, server-only types in [`server/types/`](/docs/directory-structure/server#server-types), and types shared between both in [`shared/types/`](/docs/directory-structure/shared).
49
53
  ::
@@ -20,7 +20,7 @@ Do not put any secret values inside `app.config` file. It is exposed to the user
20
20
  ::
21
21
 
22
22
  ::note
23
- When configuring a custom [`srcDir`](/docs/4.x/api/nuxt-config#srcdir), make sure to place the `app.config` file at the root of the new `srcDir` path.
23
+ When configuring a custom [`srcDir`](/docs/api/nuxt-config#srcdir), make sure to place the `app.config` file at the root of the new `srcDir` path.
24
24
  ::
25
25
 
26
26
  ## Usage
@@ -35,7 +35,7 @@ export default defineAppConfig({
35
35
  })
36
36
  ```
37
37
 
38
- We can now universally access `theme` both when server-rendering the page and in the browser using [`useAppConfig`](/docs/4.x/api/composables/use-app-config) composable.
38
+ We can now universally access `theme` both when server-rendering the page and in the browser using [`useAppConfig`](/docs/api/composables/use-app-config) composable.
39
39
 
40
40
  ```vue [app/pages/index.vue]
41
41
  <script setup lang="ts">
@@ -45,7 +45,7 @@ console.log(appConfig.theme)
45
45
  </script>
46
46
  ```
47
47
 
48
- The [`updateAppConfig`](/docs/4.x/api/utils/update-app-config) utility can be used to update the `app.config` at runtime.
48
+ The [`updateAppConfig`](/docs/api/utils/update-app-config) utility can be used to update the `app.config` at runtime.
49
49
 
50
50
  ```vue [app/pages/index.vue]
51
51
  <script setup>
@@ -59,7 +59,7 @@ console.log(appConfig) // { foo: 'baz' }
59
59
  </script>
60
60
  ```
61
61
 
62
- ::read-more{to="/docs/4.x/api/utils/update-app-config"}
62
+ ::read-more{to="/docs/api/utils/update-app-config"}
63
63
  Read more about the `updateAppConfig` utility.
64
64
  ::
65
65
 
@@ -67,7 +67,7 @@ Read more about the `updateAppConfig` utility.
67
67
 
68
68
  Nuxt tries to automatically generate a TypeScript interface from provided app config so you won't have to type it yourself.
69
69
 
70
- The fully inferred type is only available in app code (components, composables, plugins and so on). In server routes, code in the `shared/` directory and `nuxt.config`, keys defined in `app.config` files are typed as `unknown` instead: typing them there would require typechecking your app code outside the app context, where app auto-imports are not available. Keys defined inline in the `appConfig` option of `nuxt.config` are typed everywhere. If you need other keys typed outside app code, you can extend the `AppConfig` interface as described below. The location of the augmentation file determines which contexts see it: a `.d.ts` file in the `shared/` directory covers app code, shared code and server routes.
70
+ The fully inferred type is only available in app code (components, composables, plugins and so on). In server routes, code in the `shared/` directory and `nuxt.config`, keys defined in `app.config` files are typed as `unknown` instead: typing them there would require typechecking your app code outside the app context, where app auto-imports are not available. Keys defined inline in the `appConfig` option of `nuxt.config` are typed everywhere. If you need other keys typed outside app code, you can extend the `SharedAppConfig` interface as described below. The location of the augmentation file determines which contexts see it: a `.d.ts` file in the `shared/` directory covers app code, shared code and server routes.
71
71
 
72
72
  However, there are some cases where you might want to type it yourself. There are two possible things you might want to type.
73
73
 
@@ -92,7 +92,7 @@ export {}
92
92
 
93
93
  ### App Config Output
94
94
 
95
- If you want to type the result of calling [`useAppConfig()`](/docs/4.x/api/composables/use-app-config), then you will want to extend `AppConfig`.
95
+ If you want to type the result of calling [`useAppConfig()`](/docs/api/composables/use-app-config) in app code, then you will want to extend `AppConfig`. Outside app code (server routes, the `shared/` directory and `nuxt.config`) `useAppConfig()` returns `SharedAppConfig`, so extend that interface instead.
96
96
 
97
97
  ::warning
98
98
  Be careful when typing `AppConfig` as you will overwrite the types Nuxt infers from your actually defined app config.
@@ -116,7 +116,7 @@ export {}
116
116
 
117
117
  ## Merging Strategy
118
118
 
119
- Nuxt uses a custom merging strategy for the `AppConfig` within [the layers](/docs/4.x/getting-started/layers) of your application.
119
+ Nuxt uses a custom merging strategy for the `AppConfig` within [the layers](/docs/getting-started/layers) of your application.
120
120
 
121
121
  This strategy is implemented using a [Function Merger](https://github.com/unjs/defu#function-merger), which allows defining a custom merging strategy for every key in `app.config` that has an array as value.
122
122
 
@@ -13,7 +13,7 @@ If you have a `app/pages/` directory, the `app.vue` file is optional. Nuxt will
13
13
 
14
14
  ### Minimal Usage
15
15
 
16
- With Nuxt, the [`app/pages/`](/docs/4.x/directory-structure/app/pages) directory is optional. If it is not present, Nuxt will not include the [vue-router](https://router.vuejs.org) dependency. This is useful when building a landing page or an application that does not require routing.
16
+ With Nuxt, the [`app/pages/`](/docs/directory-structure/app/pages) directory is optional. If it is not present, Nuxt will not include the [vue-router](https://router.vuejs.org) dependency. This is useful when building a landing page or an application that does not require routing.
17
17
 
18
18
  ```vue [app/app.vue]
19
19
  <template>
@@ -21,11 +21,11 @@ With Nuxt, the [`app/pages/`](/docs/4.x/directory-structure/app/pages) directory
21
21
  </template>
22
22
  ```
23
23
 
24
- :link-example{to="/docs/4.x/examples/hello-world"}
24
+ :link-example{to="/docs/examples/hello-world"}
25
25
 
26
26
  ### Usage with Pages
27
27
 
28
- When you have a [`app/pages/`](/docs/4.x/directory-structure/app/pages) directory, you need to use the [`<NuxtPage>`](/docs/4.x/api/components/nuxt-page) component to display the current page:
28
+ When you have a [`app/pages/`](/docs/directory-structure/app/pages) directory, you need to use the [`<NuxtPage>`](/docs/api/components/nuxt-page) component to display the current page:
29
29
 
30
30
  ```vue [app/app.vue]
31
31
  <template>
@@ -51,13 +51,13 @@ You can also define the common structure of your application directly in `app.vu
51
51
  Remember that `app.vue` acts as the main component of your Nuxt application. Anything you add to it (JS and CSS) will be global and included in every page.
52
52
  ::
53
53
 
54
- ::read-more{to="/docs/4.x/directory-structure/app/pages"}
54
+ ::read-more{to="/docs/directory-structure/app/pages"}
55
55
  Learn more about how to structure your pages using the `app/pages/` directory.
56
56
  ::
57
57
 
58
58
  ### Usage with Layouts
59
59
 
60
- When your application requires different layouts for different pages, you can use the `app/layouts/` directory with the [`<NuxtLayout>`](/docs/4.x/api/components/nuxt-layout) component. This allows you to define multiple layouts and apply them per page.
60
+ When your application requires different layouts for different pages, you can use the `app/layouts/` directory with the [`<NuxtLayout>`](/docs/api/components/nuxt-layout) component. This allows you to define multiple layouts and apply them per page.
61
61
 
62
62
  ```vue [app/app.vue]
63
63
  <template>
@@ -67,6 +67,6 @@ When your application requires different layouts for different pages, you can us
67
67
  </template>
68
68
  ```
69
69
 
70
- ::read-more{to="/docs/4.x/directory-structure/app/layouts"}
70
+ ::read-more{to="/docs/directory-structure/app/layouts"}
71
71
  Learn more about how to structure your layouts using the `app/layouts/` directory.
72
72
  ::
@@ -23,7 +23,7 @@ const props = defineProps<{ error: NuxtError }>()
23
23
  ```
24
24
 
25
25
  ::note
26
- Although it is called an 'error page' it's not a route and shouldn't be placed in your `~/pages` directory. For the same reason, you shouldn't use `definePageMeta` within this page. That being said, you can still use layouts in the error file, by utilizing the [`NuxtLayout`](/docs/4.x/api/components/nuxt-layout) component and specifying the name of the layout.
26
+ Although it is called an 'error page' it's not a route and shouldn't be placed in your `~/pages` directory. For the same reason, you shouldn't use `definePageMeta` within this page. That being said, you can still use layouts in the error file, by utilizing the [`NuxtLayout`](/docs/api/components/nuxt-layout) component and specifying the name of the layout.
27
27
  ::
28
28
 
29
29
  The error page has a single prop - `error` which contains an error for you to handle.
@@ -36,7 +36,7 @@ The module automatically loads and parses them.
36
36
 
37
37
  ## Render Content
38
38
 
39
- To render content pages, add a [catch-all route](/docs/4.x/directory-structure/app/pages/#catch-all-route) using the [`<ContentRenderer>`](https://content.nuxt.com/docs/components/content-renderer) component:
39
+ To render content pages, add a [catch-all route](/docs/directory-structure/app/pages/#catch-all-route) using the [`<ContentRenderer>`](https://content.nuxt.com/docs/components/content-renderer) component:
40
40
 
41
41
  ```vue [app/pages/[...slug\\].vue]
42
42
  <script lang="ts" setup>
@@ -64,17 +64,17 @@ Named layer aliases were introduced in Nuxt v3.16.0.
64
64
 
65
65
  Each layer can include:
66
66
 
67
- - [`nuxt.config.ts`](/docs/4.x/directory-structure/nuxt-config) - Layer-specific configuration that will be merged with the main config
68
- - [`app.config.ts`](/docs/4.x/directory-structure/app/app-config) - Reactive application configuration
69
- - [`app/components/`](/docs/4.x/directory-structure/app/components) - Vue components (auto-imported)
70
- - [`app/composables/`](/docs/4.x/directory-structure/app/composables) - Vue composables (auto-imported)
71
- - [`app/utils/`](/docs/4.x/directory-structure/app/utils) - Utility functions (auto-imported)
72
- - [`app/pages/`](/docs/4.x/directory-structure/app/pages) - Application pages
73
- - [`app/layouts/`](/docs/4.x/directory-structure/app/layouts) - Application layouts
74
- - [`app/middleware/`](/docs/4.x/directory-structure/app/middleware) - Route middleware
75
- - [`app/plugins/`](/docs/4.x/directory-structure/app/plugins) - Nuxt plugins
76
- - [`server/`](/docs/4.x/directory-structure/server) - Server routes, middleware, and utilities
77
- - [`shared/`](/docs/4.x/directory-structure/shared) - Shared code between app and server
67
+ - [`nuxt.config.ts`](/docs/directory-structure/nuxt-config) - Layer-specific configuration that will be merged with the main config
68
+ - [`app.config.ts`](/docs/directory-structure/app/app-config) - Reactive application configuration
69
+ - [`app/components/`](/docs/directory-structure/app/components) - Vue components (auto-imported)
70
+ - [`app/composables/`](/docs/directory-structure/app/composables) - Vue composables (auto-imported)
71
+ - [`app/utils/`](/docs/directory-structure/app/utils) - Utility functions (auto-imported)
72
+ - [`app/pages/`](/docs/directory-structure/app/pages) - Application pages
73
+ - [`app/layouts/`](/docs/directory-structure/app/layouts) - Application layouts
74
+ - [`app/middleware/`](/docs/directory-structure/app/middleware) - Route middleware
75
+ - [`app/plugins/`](/docs/directory-structure/app/plugins) - Nuxt plugins
76
+ - [`server/`](/docs/directory-structure/server) - Server routes, middleware, and utilities
77
+ - [`shared/`](/docs/directory-structure/shared) - Shared code between app and server
78
78
 
79
79
  ## Priority Order
80
80
 
@@ -82,8 +82,8 @@ When multiple layers define the same resource (component, composable, page, etc.
82
82
 
83
83
  To control the order, prefix directories with numbers: `1.base/`, `2.features/`, `3.admin/`.
84
84
 
85
- Alternatively, reference the directories in [`extends`](/docs/4.x/api/nuxt-config#extends) (e.g. `extends: ['~~/layers/admin', '~~/layers/base']`) to order them from `nuxt.config` without renaming, with the first entry taking the highest priority.
85
+ Alternatively, reference the directories in [`extends`](/docs/api/nuxt-config#extends) (e.g. `extends: ['~~/layers/admin', '~~/layers/base']`) to order them from `nuxt.config` without renaming, with the first entry taking the highest priority.
86
86
 
87
- :read-more{to="/docs/4.x/getting-started/layers#layer-priority"}
87
+ :read-more{to="/docs/getting-started/layers#layer-priority"}
88
88
 
89
89
  :video-accordion{title="Watch a video from Learn Vue about Nuxt Layers" videoId="lnFCM7c9f7I"}
@@ -11,7 +11,7 @@ The auto-registered files patterns are:
11
11
  - `modules/*/index.ts`
12
12
  - `modules/*.ts`
13
13
 
14
- You don't need to add those local modules to your [`nuxt.config.ts`](/docs/4.x/directory-structure/nuxt-config) separately.
14
+ You don't need to add those local modules to your [`nuxt.config.ts`](/docs/directory-structure/nuxt-config) separately.
15
15
 
16
16
  ::code-group
17
17
 
@@ -57,7 +57,7 @@ Note that all components, pages, composables and other files that would be norma
57
57
  ::
58
58
 
59
59
  Modules are executed in the following sequence:
60
- - First, the modules defined in [`nuxt.config.ts`](/docs/4.x/api/nuxt-config#modules-1) are loaded.
60
+ - First, the modules defined in [`nuxt.config.ts`](/docs/api/nuxt-config#modules-1) are loaded.
61
61
  - Then, modules found in the `modules/` directory are executed, and they load in alphabetical order.
62
62
 
63
63
  You can change the order of local module by adding a number to the front of each directory name:
@@ -69,7 +69,7 @@ modules/
69
69
  2.second-module.ts
70
70
  ```
71
71
 
72
- :read-more{to="/docs/4.x/guide/modules"}
72
+ :read-more{to="/docs/guide/modules"}
73
73
 
74
74
  ::tip{icon="i-lucide-video" to="https://vueschool.io/lessons/creating-your-first-module-from-scratch?friend=nuxt" target="_blank"}
75
75
  Watch Vue School video about Nuxt private modules.
@@ -8,5 +8,5 @@ navigation.icon: i-vscode-icons-folder-type-node
8
8
  The package manager ([`npm`](https://docs.npmjs.com/cli/commands/npm/) or [`yarn`](https://yarnpkg.com) or [`pnpm`](https://pnpm.io/cli/install) or [`bun`](https://bun.com/package-manager) or [`deno`](https://docs.deno.com/runtime/getting_started/installation/)) creates this directory to store the dependencies of your project.
9
9
 
10
10
  ::important
11
- This directory should be added to your [`.gitignore`](/docs/4.x/directory-structure/gitignore) file to avoid pushing the dependencies to your repository.
11
+ This directory should be added to your [`.gitignore`](/docs/directory-structure/gitignore) file to avoid pushing the dependencies to your repository.
12
12
  ::
@@ -25,7 +25,7 @@ The handler can directly return JSON data, a `Promise`, or use `event.node.res.e
25
25
  Do not import Vue app code (components, composables, or other app-only utilities) in your server routes or utilities, and do not import server-only code in your app.
26
26
  ::
27
27
 
28
- :read-more{to="/docs/4.x/directory-structure/shared#why-you-cannot-mix-vue-and-nitro-code" title="Why You Cannot Mix Vue and Nitro Code"}
28
+ :read-more{to="/docs/directory-structure/shared#why-you-cannot-mix-vue-and-nitro-code" title="Why You Cannot Mix Vue and Nitro Code"}
29
29
 
30
30
  ```ts twoslash [server/api/hello.ts]
31
31
  export default defineEventHandler((event) => {
@@ -64,7 +64,7 @@ export default defineEventHandler(() => 'Hello World!')
64
64
  Given the example above, the `/hello` route will be accessible at <http://localhost:3000/hello>.
65
65
 
66
66
  ::note
67
- Note that currently server routes do not support the full functionality of dynamic routes as [pages](/docs/4.x/directory-structure/app/pages#dynamic-routes) do.
67
+ Note that currently server routes do not support the full functionality of dynamic routes as [pages](/docs/directory-structure/app/pages#dynamic-routes) do.
68
68
  ::
69
69
 
70
70
  ## Server Middleware
@@ -160,7 +160,25 @@ The `#server` alias can only be used within the `server/` directory. Importing f
160
160
 
161
161
  Auto-imports and other types are different for the `server/` directory, as it is running in a different context from the `app/` directory.
162
162
 
163
- By default, Nuxt 4 generates a [`tsconfig.json`](/docs/4.x/directory-structure/tsconfig) which includes a project reference covering the `server/` folder which ensures accurate typings.
163
+ By default, Nuxt 4 generates a [`tsconfig.json`](/docs/directory-structure/tsconfig) which includes a project reference covering the `server/` folder which ensures accurate typings.
164
+
165
+ Types placed in `~~/server/types/` are auto-imported in the server context only, so you can reference them in server routes, middleware, plugins, and utilities without importing them. Types that are also needed in the Vue app belong in [`shared/types/`](/docs/directory-structure/shared) instead.
166
+
167
+ ```ts twoslash [server/types/todo.ts]
168
+ export interface Todo {
169
+ id: string
170
+ title: string
171
+ completed: boolean
172
+ }
173
+ ```
174
+
175
+ ```ts [server/api/todos.get.ts]
176
+ export default defineEventHandler((): Todo[] => {
177
+ return []
178
+ })
179
+ ```
180
+
181
+ Only files directly in `server/types/` are scanned; files in nested subdirectories are not auto-imported, matching how [`shared/types/`](/docs/directory-structure/shared#how-files-are-scanned) works.
164
182
 
165
183
  ## Recipes
166
184
 
@@ -177,7 +195,7 @@ export default defineEventHandler((event) => {
177
195
  ```
178
196
 
179
197
  ::tip{to="https://h3.dev/examples/validate-data#validate-params"}
180
- Alternatively, use `getValidatedRouterParams` with a schema validator such as Zod for runtime and type safety.
198
+ Alternatively, use `getValidatedRouterParams` with a schema validator such as Zod or Valibot for runtime and type safety.
181
199
  ::
182
200
 
183
201
  You can now universally call this API on `/api/hello/nuxt` and get `Hello, nuxt!`.
@@ -253,7 +271,7 @@ export default defineEventHandler(async (event) => {
253
271
  ```
254
272
 
255
273
  ::tip{to="https://unjs.io/blog/2023-08-15-h3-towards-the-edge-of-the-web/#runtime-type-safe-request-utils"}
256
- Alternatively, use `readValidatedBody` with a schema validator such as Zod for runtime and type safety.
274
+ Alternatively, use `readValidatedBody` with a schema validator such as Zod or Valibot for runtime and type safety.
257
275
  ::
258
276
 
259
277
  You can now universally call this API using:
@@ -286,7 +304,7 @@ export default defineEventHandler((event) => {
286
304
  ```
287
305
 
288
306
  ::tip{to="https://unjs.io/blog/2023-08-15-h3-towards-the-edge-of-the-web#runtime-type-safe-request-utils"}
289
- Alternatively, use `getValidatedQuery` with a schema validator such as Zod for runtime and type safety.
307
+ Alternatively, use `getValidatedQuery` with a schema validator such as Zod or Valibot for runtime and type safety.
290
308
  ::
291
309
 
292
310
  ### Error Handling
@@ -295,7 +313,7 @@ If no errors are thrown, a status code of `200 OK` will be returned.
295
313
 
296
314
  Any uncaught errors will return a `500 Internal Server Error` HTTP Error.
297
315
 
298
- To return other error codes, throw an exception with [`createError`](/docs/4.x/api/utils/create-error):
316
+ To return other error codes, throw an exception with [`createError`](/docs/api/utils/create-error):
299
317
 
300
318
  ```ts [server/api/validation/[id\\].ts]
301
319
  export default defineEventHandler((event) => {
@@ -313,7 +331,7 @@ export default defineEventHandler((event) => {
313
331
 
314
332
  ### Status Codes
315
333
 
316
- To return other status codes, use the [`setResponseStatus`](/docs/4.x/api/utils/set-response-status) utility.
334
+ To return other status codes, use the [`setResponseStatus`](/docs/api/utils/set-response-status) utility.
317
335
 
318
336
  For example, to return `202 Accepted`
319
337
 
@@ -352,7 +370,7 @@ NUXT_GITHUB_TOKEN='<my-super-token>'
352
370
  ::
353
371
 
354
372
  ::note
355
- Giving the `event` as argument to `useRuntimeConfig` is optional, but it is recommended to pass it to get the runtime config overwritten by [environment variables](/docs/4.x/guide/going-further/runtime-config#environment-variables) at runtime for server routes.
373
+ Giving the `event` as argument to `useRuntimeConfig` is optional, but it is recommended to pass it to get the runtime config overwritten by [environment variables](/docs/guide/going-further/runtime-config#environment-variables) at runtime for server routes.
356
374
  ::
357
375
 
358
376
  ### Request Cookies
@@ -418,7 +436,7 @@ export default defineNuxtConfig({
418
436
  })
419
437
  ```
420
438
 
421
- :read-more{to="/docs/4.x/guide/concepts/server-engine"}
439
+ :read-more{to="/docs/guide/concepts/server-engine"}
422
440
 
423
441
  ### Nested Router
424
442
 
@@ -438,12 +456,13 @@ export default useBase('/api/hello', router.handler)
438
456
  This is an experimental feature and is available in all environments.
439
457
  ::
440
458
 
459
+ You can return streams directly from the event handler.
460
+
441
461
  ```ts [server/api/foo.get.ts]
442
462
  import fs from 'node:fs'
443
- import { sendStream } from 'h3'
444
463
 
445
- export default defineEventHandler((event) => {
446
- return sendStream(event, fs.createReadStream('/path/to/file'))
464
+ export default defineEventHandler(() => {
465
+ return fs.createReadStream('/path/to/file')
447
466
  })
448
467
  ```
449
468
 
@@ -480,7 +499,7 @@ Never combine `next()` callback with a legacy middleware that is `async` or retu
480
499
 
481
500
  ### Server Storage
482
501
 
483
- Nitro provides a cross-platform [storage layer](https://nitro.build/guide/storage). In order to configure additional storage mount points, you can use `nitro.storage`, or [server plugins](/docs/4.x/directory-structure/server#server-plugins).
502
+ Nitro provides a cross-platform [storage layer](https://nitro.build/guide/storage). In order to configure additional storage mount points, you can use `nitro.storage`, or [server plugins](/docs/directory-structure/server#server-plugins).
484
503
 
485
504
  **Example of adding a Redis storage:**
486
505
 
@@ -29,7 +29,9 @@ Server-only code (such as Node APIs, Nitro utilities, or server route handlers)
29
29
 
30
30
  ### Type-Only Imports
31
31
 
32
- `import type` is erased at compile time and does not pull runtime code into the other bundle, so importing only types across the boundary may appear to work. Even so, keep shared types (such as API response types) in `shared/types/`, where they are auto-imported in both contexts. This keeps the boundary clear, avoids accidentally turning a type import into a value import later, and matches Nuxt's separate [type contexts](/docs/4.x/guide/concepts/typescript#project-references) for app, server, and shared code.
32
+ `import type` is erased at compile time and does not pull runtime code into the other bundle, so importing only types across the boundary may appear to work. Even so, keep shared types (such as API response types) in `shared/types/`, where they are auto-imported in both contexts. This keeps the boundary clear, avoids accidentally turning a type import into a value import later, and matches Nuxt's separate [type contexts](/docs/guide/concepts/typescript#project-references) for app, server, and shared code.
33
+
34
+ Types that are only used in one context can live next to that context instead: `app/types/` is auto-imported in the Vue app only, and [`server/types/`](/docs/directory-structure/server#server-types) is auto-imported in the Nitro server only. Use `shared/types/` when a type is needed in both.
33
35
 
34
36
  :video-accordion{title="Watch a video from Vue School on sharing utils and types between app and server" videoId="nnAR-MO3q5M"}
35
37
 
@@ -51,7 +53,7 @@ export default function (input: string) {
51
53
  }
52
54
  ```
53
55
 
54
- You can now use [auto-imported](/docs/4.x/directory-structure/shared) utilities in your Nuxt app and `server/` directory.
56
+ You can now use [auto-imported](/docs/directory-structure/shared) utilities in your Nuxt app and `server/` directory.
55
57
 
56
58
  ```vue [app/app.vue]
57
59
  <script setup lang="ts">
@@ -78,10 +80,10 @@ export default defineEventHandler((event) => {
78
80
  Only files in the `shared/utils/` and `shared/types/` directories will be auto-imported. Files nested within subdirectories of these directories will not be auto-imported unless you add these directories to `imports.dirs` and `nitro.imports.dirs`.
79
81
 
80
82
  ::tip
81
- The way `shared/utils` and `shared/types` auto-imports work and are scanned is identical to the [`app/composables/`](/docs/4.x/directory-structure/app/composables) and [`app/utils/`](/docs/4.x/directory-structure/app/utils) directories.
83
+ The way `shared/utils` and `shared/types` auto-imports work and are scanned is identical to the [`app/composables/`](/docs/directory-structure/app/composables) and [`app/utils/`](/docs/directory-structure/app/utils) directories.
82
84
  ::
83
85
 
84
- :read-more{to="/docs/4.x/directory-structure/app/composables#how-files-are-scanned"}
86
+ :read-more{to="/docs/directory-structure/app/composables#how-files-are-scanned"}
85
87
 
86
88
  ```bash [Directory Structure]
87
89
  -| shared/
@@ -111,4 +113,4 @@ import upper from '#shared/utils/formatters/upper'
111
113
 
112
114
  This alias ensures consistent imports across your application, regardless of the importing file's location.
113
115
 
114
- :read-more{to="/docs/4.x/guide/concepts/auto-imports"}
116
+ :read-more{to="/docs/guide/concepts/auto-imports"}
@@ -0,0 +1,25 @@
1
+ ---
2
+ title: 'test'
3
+ head.title: 'test/'
4
+ description: 'Use the test/ directory to organize unit, Nuxt, and end-to-end tests for your application.'
5
+ navigation.icon: i-vscode-icons-folder-type-test
6
+ ---
7
+
8
+ The `test/` directory is the recommended place for your application tests. Nuxt does not scan it the way it does `app/` or `server/`; you choose the runner and layout yourself (typically with [`@nuxt/test-utils`](/docs/getting-started/testing)).
9
+
10
+ A common layout separates environments:
11
+
12
+ ```bash [Directory structure]
13
+ -| test/
14
+ ---| e2e/
15
+ ---| nuxt/
16
+ ---| unit/
17
+ ```
18
+
19
+ - `test/unit/` — fast Node tests without the Nuxt runtime
20
+ - `test/nuxt/` — tests that need the Nuxt runtime environment
21
+ - `test/e2e/` — end-to-end tests against a running app
22
+
23
+ ::read-more{to="/docs/getting-started/testing#organizing-your-tests"}
24
+ See **Organizing Your Tests** for setup, Vitest projects, and TypeScript context.
25
+ ::
@@ -6,12 +6,12 @@ navigation.icon: i-vscode-icons-file-type-dotenv
6
6
  ---
7
7
 
8
8
  ::important
9
- This file should be added to your [`.gitignore`](/docs/4.x/directory-structure/gitignore) file to avoid pushing secrets to your repository.
9
+ This file should be added to your [`.gitignore`](/docs/directory-structure/gitignore) file to avoid pushing secrets to your repository.
10
10
  ::
11
11
 
12
12
  ## Dev, Build and Generate Time
13
13
 
14
- Nuxt CLI has built-in [dotenv](https://github.com/motdotla/dotenv) support in development mode and when running [`nuxt build`](/docs/4.x/api/commands/build) and [`nuxt generate`](/docs/4.x/api/commands/generate).
14
+ Nuxt CLI has built-in `.env` support via [c12](https://github.com/unjs/c12) in development mode and when running [`nuxt build`](/docs/api/commands/build) and [`nuxt generate`](/docs/api/commands/generate).
15
15
 
16
16
  In addition to any process environment variables, if you have a `.env` file in your project root directory, it will be automatically loaded **at dev, build and generate time**. Any environment variables set there will be accessible within your `nuxt.config` file and modules.
17
17
 
@@ -34,7 +34,7 @@ npx nuxt dev --dotenv .env.local
34
34
  When updating `.env` in development mode, the Nuxt instance is automatically restarted to apply new values to the `process.env`.
35
35
 
36
36
  ::important
37
- In your application code, you should use [Runtime Config](/docs/4.x/guide/going-further/runtime-config) instead of plain env variables.
37
+ In your application code, you should use [Runtime Config](/docs/guide/going-further/runtime-config) instead of plain env variables.
38
38
  ::
39
39
 
40
40
  ## Production
@@ -56,12 +56,12 @@ Since `.env` files are not used in production, you must explicitly set environme
56
56
  * Many cloud service providers, such as Vercel, Netlify, and AWS, provide interfaces for setting environment variables via their dashboards, CLI tools or configuration files.
57
57
 
58
58
  ::important
59
- `runtimeConfig` [won't pick up environment variables that don't start with `NUXT_` in production] (https://nuxt.com/docs/4.x/guide/going-further/runtime-config#environment-variables).
59
+ `runtimeConfig` [won't pick up environment variables that don't start with `NUXT_` in production] (/docs/guide/going-further/runtime-config#environment-variables).
60
60
  ::
61
61
 
62
62
  ## Production Preview
63
63
 
64
- For local production preview purpose, we recommend using [`nuxt preview`](/docs/4.x/api/commands/preview) since using this command, the `.env` file will be loaded into `process.env` for convenience. Note that this command requires dependencies to be installed in the package directory.
64
+ For local production preview purpose, we recommend using [`nuxt preview`](/docs/api/commands/preview) since using this command, the `.env` file will be loaded into `process.env` for convenience. Note that this command requires dependencies to be installed in the package directory.
65
65
 
66
66
  Or you could pass the environment variables as arguments using the terminal. For example, on Linux or macOS:
67
67
 
@@ -71,9 +71,9 @@ NODE_ENV=production DATABASE_HOST=mydatabaseconnectionstring node .output/server
71
71
 
72
72
  Note that for a purely static site, it is not possible to set runtime configuration config after your project is prerendered.
73
73
 
74
- :read-more{to="/docs/4.x/guide/going-further/runtime-config"}
74
+ :read-more{to="/docs/guide/going-further/runtime-config"}
75
75
 
76
76
  ::note
77
77
  If you want to use environment variables set at build time but do not care about updating these down the line (or only need to update them reactively _within_ your app) then `appConfig` may be a better choice. You can define `appConfig` both within your `nuxt.config` (using environment variables) and also within an `~/app.config.ts` file in your project.
78
- :read-more{to="/docs/4.x/directory-structure/app/app-config"}
78
+ :read-more{to="/docs/directory-structure/app/app-config"}
79
79
  ::
@@ -6,12 +6,12 @@ navigation.icon: i-vscode-icons-file-type-nuxt
6
6
 
7
7
  ---
8
8
 
9
- The `.nuxtignore` file tells Nuxt to ignore files in your project’s root directory ([`rootDir`](/docs/4.x/api/nuxt-config#rootdir)) during the build phase.
9
+ The `.nuxtignore` file tells Nuxt to ignore files in your project’s root directory ([`rootDir`](/docs/api/nuxt-config#rootdir)) during the build phase.
10
10
 
11
- It is subject to the same specification as [`.gitignore`](/docs/4.x/directory-structure/gitignore) and `.eslintignore` files, in which each line is a glob pattern indicating which files should be ignored.
11
+ It is subject to the same specification as [`.gitignore`](/docs/directory-structure/gitignore) and `.eslintignore` files, in which each line is a glob pattern indicating which files should be ignored.
12
12
 
13
13
  ::tip
14
- You can also configure [`ignoreOptions`](/docs/4.x/api/nuxt-config#ignoreoptions), [`ignorePrefix`](/docs/4.x/api/nuxt-config#ignoreprefix) and [`ignore`](/docs/4.x/api/nuxt-config#ignore) in your `nuxt.config` file.
14
+ You can also configure [`ignoreOptions`](/docs/api/nuxt-config#ignoreoptions), [`ignorePrefix`](/docs/api/nuxt-config#ignoreprefix) and [`ignore`](/docs/api/nuxt-config#ignore) in your `nuxt.config` file.
15
15
  ::
16
16
 
17
17
  ## Usage
@@ -8,7 +8,7 @@ navigation.icon: i-vscode-icons-file-type-nuxt
8
8
  The `.nuxtrc` file can be used to configure Nuxt with a flat syntax. It is based on [`unjs/rc9`](https://github.com/unjs/rc9).
9
9
 
10
10
  ::tip
11
- For more advanced configurations, use [`nuxt.config`](/docs/4.x/directory-structure/nuxt-config).
11
+ For more advanced configurations, use [`nuxt.config`](/docs/directory-structure/nuxt-config).
12
12
  ::
13
13
 
14
14
  ## Usage
@@ -31,10 +31,10 @@ setups.@nuxt/test-utils="3.23.0"
31
31
  If present, the properties in the `nuxt.config` file will overwrite the properties in `.nuxtrc` file.
32
32
 
33
33
  ::note
34
- Nuxt automatically adds a `setups` section to track module installation and upgrade state. This is used internally for [module lifecycle hooks](/docs/4.x/api/kit/modules#using-lifecycle-hooks-for-module-installation-and-upgrade) and should not be modified manually.
34
+ Nuxt automatically adds a `setups` section to track module installation and upgrade state. This is used internally for [module lifecycle hooks](/docs/api/kit/modules#using-lifecycle-hooks-for-module-installation-and-upgrade) and should not be modified manually.
35
35
  ::
36
36
 
37
- ::read-more{to="/docs/4.x/api/configuration/nuxt-config"}
37
+ ::read-more{to="/docs/api/configuration/nuxt-config"}
38
38
  Discover all the available options in the **Nuxt configuration** documentation.
39
39
  ::
40
40
 
@@ -27,8 +27,8 @@ export default defineNuxtConfig({
27
27
  })
28
28
  ```
29
29
 
30
- ::read-more{to="/docs/4.x/api/configuration/nuxt-config"}
30
+ ::read-more{to="/docs/api/configuration/nuxt-config"}
31
31
  Discover all the available options in the **Nuxt configuration** documentation.
32
32
  ::
33
33
 
34
- To ensure your configuration is up to date, Nuxt will make a full restart when detecting changes in the main configuration file, the [`.env`](/docs/4.x/directory-structure/env), [`.nuxtignore`](/docs/4.x/directory-structure/nuxtignore) and [`.nuxtrc`](/docs/4.x/directory-structure/nuxtrc) dotfiles.
34
+ To ensure your configuration is up to date, Nuxt will make a full restart when detecting changes in the main configuration file, the [`.env`](/docs/directory-structure/env), [`.nuxtignore`](/docs/directory-structure/nuxtignore) and [`.nuxtrc`](/docs/directory-structure/nuxtrc) dotfiles.
@@ -5,7 +5,7 @@ head.title: "tsconfig.json"
5
5
  navigation.icon: i-vscode-icons-file-type-tsconfig
6
6
  ---
7
7
 
8
- Nuxt [automatically generates](/docs/4.x/guide/concepts/typescript#auto-generated-types) multiple TypeScript configuration files (`.nuxt/tsconfig.app.json`, `.nuxt/tsconfig.server.json`, `.nuxt/tsconfig.node.json` and `.nuxt/tsconfig.shared.json`) that include recommended basic TypeScript configuration for your project, references to [auto-imports](/docs/4.x/guide/concepts/auto-imports), [API route types](/docs/4.x/guide/concepts/server-engine#typed-api-routes), path aliases, and more.
8
+ Nuxt [automatically generates](/docs/guide/concepts/typescript#auto-generated-types) multiple TypeScript configuration files (`.nuxt/tsconfig.app.json`, `.nuxt/tsconfig.server.json`, `.nuxt/tsconfig.node.json` and `.nuxt/tsconfig.shared.json`) that include recommended basic TypeScript configuration for your project, references to [auto-imports](/docs/guide/concepts/auto-imports), [API route types](/docs/guide/concepts/server-engine#typed-api-routes), path aliases, and more.
9
9
 
10
10
  Your Nuxt project should include the following `tsconfig.json` file at the root of the project:
11
11
 
@@ -33,20 +33,26 @@ Your Nuxt project should include the following `tsconfig.json` file at the root
33
33
  We do not recommend modifying the contents of this file directly, as doing so could overwrite important settings that Nuxt or other modules rely on. Instead, extend it via `nuxt.config.ts`.
34
34
  ::
35
35
 
36
- ::read-more{to="/docs/4.x/guide/concepts/typescript#project-references"}
36
+ ::read-more{to="/docs/guide/concepts/typescript#project-references"}
37
37
  Read more about the different type contexts of a Nuxt project here.
38
38
  ::
39
39
 
40
40
  ## Extending TypeScript Configuration
41
41
 
42
- You can customize the TypeScript configuration of your Nuxt project for each context (`app`, `shared`, `node`, and `server`) in the `nuxt.config.ts` file.
42
+ You can customize the TypeScript configuration of your Nuxt project in the `nuxt.config.ts` file: set shared `compilerOptions` for every context at once with `typescript.tsConfig`, and override them for each context (`app`, `shared`, `node`, and `server`) individually.
43
43
  <!-- @case-police-ignore tsConfig -->
44
44
  ```ts twoslash [nuxt.config.ts]
45
45
  // @errors: 2353
46
46
  export default defineNuxtConfig({
47
47
  typescript: {
48
- // customize tsconfig.app.json
48
+ // shared compiler options for every generated tsconfig
49
49
  tsConfig: {
50
+ compilerOptions: {
51
+ // ...
52
+ },
53
+ },
54
+ // customize tsconfig.app.json
55
+ appTsConfig: {
50
56
  // ...
51
57
  },
52
58
  // customize tsconfig.shared.json
@@ -57,14 +63,18 @@ export default defineNuxtConfig({
57
63
  nodeTsConfig: {
58
64
  // ...
59
65
  },
60
- },
61
- nitro: {
62
- typescript: {
63
- // customize tsconfig.server.json
64
- tsConfig: {
65
- // ...
66
- },
66
+ // customize tsconfig.server.json
67
+ serverTsConfig: {
68
+ // ...
67
69
  },
68
70
  },
69
71
  })
70
72
  ```
73
+
74
+ ::note
75
+ Most `compilerOptions` set in `typescript.tsConfig` are shared with every context, but a few are not. DOM- and Vue-specific options (such as `lib`, `jsx` and `jsxImportSource`) only make sense for your application code, so they are applied to `tsconfig.app.json` alone. Nuxt also manages `types`, `paths` and `noEmit` per context (the `node`, `shared` and `server` configs deliberately emit nothing and scan no ambient types), so setting these in `typescript.tsConfig` will not change them. Use the matching per-context option (`appTsConfig`, `nodeTsConfig`, `sharedTsConfig` or `serverTsConfig`) when you need to override them.
76
+ ::
77
+
78
+ ::note
79
+ `typescript.serverTsConfig` extends `tsconfig.server.json`. `nitro.typescript.tsConfig` is kept in sync with it but is deprecated, so set `typescript.serverTsConfig` instead.
80
+ ::