@nuxt/docs 4.2.1 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/1.getting-started/01.introduction.md +1 -1
  2. package/1.getting-started/02.installation.md +2 -5
  3. package/1.getting-started/03.configuration.md +27 -27
  4. package/1.getting-started/04.views.md +5 -5
  5. package/1.getting-started/05.assets.md +7 -7
  6. package/1.getting-started/06.styling.md +9 -5
  7. package/1.getting-started/07.routing.md +8 -8
  8. package/1.getting-started/08.seo-meta.md +7 -3
  9. package/1.getting-started/09.transitions.md +6 -6
  10. package/1.getting-started/10.data-fetching.md +2 -2
  11. package/1.getting-started/11.state-management.md +2 -2
  12. package/1.getting-started/12.error-handling.md +15 -9
  13. package/1.getting-started/13.server.md +2 -2
  14. package/1.getting-started/14.layers.md +50 -16
  15. package/1.getting-started/15.prerendering.md +6 -0
  16. package/1.getting-started/16.deployment.md +2 -1
  17. package/1.getting-started/17.testing.md +44 -3
  18. package/1.getting-started/18.upgrade.md +37 -24
  19. package/{2.guide/1.directory-structure → 2.directory-structure}/0.nuxt.md +1 -1
  20. package/{2.guide/1.directory-structure → 2.directory-structure}/0.output.md +1 -1
  21. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.assets.md +2 -2
  22. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.components.md +6 -2
  23. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.composables.md +2 -2
  24. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.layouts.md +35 -3
  25. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.middleware.md +1 -1
  26. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.pages.md +28 -7
  27. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.plugins.md +5 -2
  28. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.utils.md +3 -3
  29. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/3.app.md +4 -4
  30. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/3.error.md +10 -8
  31. package/{2.guide/1.directory-structure → 2.directory-structure}/1.content.md +2 -2
  32. package/2.directory-structure/1.layers.md +87 -0
  33. package/{2.guide/1.directory-structure → 2.directory-structure}/1.modules.md +13 -3
  34. package/{2.guide/1.directory-structure → 2.directory-structure}/1.node_modules.md +2 -2
  35. package/{2.guide/1.directory-structure → 2.directory-structure}/1.server.md +27 -7
  36. package/{2.guide/1.directory-structure → 2.directory-structure}/1.shared.md +3 -3
  37. package/{2.guide/1.directory-structure → 2.directory-structure}/2.env.md +2 -2
  38. package/{2.guide/1.directory-structure → 2.directory-structure}/2.nuxtignore.md +1 -1
  39. package/{2.guide/1.directory-structure → 2.directory-structure}/2.nuxtrc.md +4 -1
  40. package/{2.guide/1.directory-structure → 2.directory-structure}/3.nuxt-config.md +1 -1
  41. package/{2.guide/1.directory-structure → 2.directory-structure}/3.package.md +1 -1
  42. package/{2.guide/1.directory-structure → 2.directory-structure}/3.tsconfig.md +1 -0
  43. package/2.directory-structure/index.md +65 -0
  44. package/{2.guide → 3.guide}/0.index.md +10 -7
  45. package/{2.guide/2.concepts/3.rendering.md → 3.guide/1.concepts/1.rendering.md} +2 -27
  46. package/{2.guide/2.concepts/2.vuejs-development.md → 3.guide/1.concepts/10.vuejs-development.md} +4 -3
  47. package/{2.guide/2.concepts/10.nuxt-lifecycle.md → 3.guide/1.concepts/2.nuxt-lifecycle.md} +33 -26
  48. package/{2.guide/2.concepts/1.auto-imports.md → 3.guide/1.concepts/3.auto-imports.md} +5 -5
  49. package/{2.guide/2.concepts → 3.guide/1.concepts}/4.server-engine.md +3 -3
  50. package/{2.guide/2.concepts → 3.guide/1.concepts}/5.modules.md +15 -2
  51. package/{2.guide/2.concepts → 3.guide/1.concepts}/7.esm.md +1 -0
  52. package/{2.guide/2.concepts → 3.guide/1.concepts}/8.typescript.md +9 -5
  53. package/{2.guide/5.best-practices → 3.guide/2.best-practices}/performance.md +2 -2
  54. package/3.guide/3.ai/.navigation.yml +3 -0
  55. package/3.guide/3.ai/1.mcp.md +277 -0
  56. package/3.guide/3.ai/2.llms-txt.md +65 -0
  57. package/3.guide/4.modules/.navigation.yml +3 -0
  58. package/3.guide/4.modules/1.getting-started.md +103 -0
  59. package/3.guide/4.modules/2.module-anatomy.md +138 -0
  60. package/3.guide/4.modules/3.recipes-basics.md +330 -0
  61. package/3.guide/4.modules/4.recipes-advanced.md +243 -0
  62. package/3.guide/4.modules/5.testing.md +76 -0
  63. package/3.guide/4.modules/6.best-practices.md +104 -0
  64. package/3.guide/4.modules/7.ecosystem.md +32 -0
  65. package/3.guide/4.modules/index.md +36 -0
  66. package/{2.guide/4.recipes → 3.guide/5.recipes}/1.custom-routing.md +1 -1
  67. package/{2.guide/4.recipes → 3.guide/5.recipes}/2.vite-plugin.md +5 -1
  68. package/{2.guide/4.recipes → 3.guide/5.recipes}/3.custom-usefetch.md +2 -2
  69. package/{2.guide/4.recipes → 3.guide/5.recipes}/4.sessions-and-authentication.md +2 -2
  70. package/{2.guide/3.going-further → 3.guide/6.going-further}/1.events.md +2 -3
  71. package/{2.guide/3.going-further → 3.guide/6.going-further}/1.experimental-features.md +19 -4
  72. package/{2.guide/3.going-further → 3.guide/6.going-further}/1.internals.md +5 -4
  73. package/{2.guide/3.going-further → 3.guide/6.going-further}/10.runtime-config.md +3 -3
  74. package/{2.guide/3.going-further → 3.guide/6.going-further}/2.hooks.md +3 -3
  75. package/{2.guide/3.going-further → 3.guide/6.going-further}/4.kit.md +1 -1
  76. package/{2.guide/3.going-further → 3.guide/6.going-further}/6.nuxt-app.md +3 -3
  77. package/{2.guide/3.going-further → 3.guide/6.going-further}/7.layers.md +38 -12
  78. package/{3.api → 4.api}/1.components/1.nuxt-client-fallback.md +4 -0
  79. package/{3.api → 4.api}/1.components/12.nuxt-route-announcer.md +1 -3
  80. package/{3.api → 4.api}/1.components/13.nuxt-time.md +0 -2
  81. package/{3.api → 4.api}/1.components/2.nuxt-page.md +2 -2
  82. package/{3.api → 4.api}/1.components/3.nuxt-layout.md +6 -6
  83. package/{3.api → 4.api}/1.components/5.nuxt-loading-indicator.md +1 -1
  84. package/{3.api → 4.api}/1.components/7.nuxt-welcome.md +2 -2
  85. package/{3.api → 4.api}/1.components/8.nuxt-island.md +9 -2
  86. package/{3.api → 4.api}/2.composables/use-app-config.md +1 -1
  87. package/{3.api → 4.api}/2.composables/use-async-data.md +3 -3
  88. package/4.api/2.composables/use-cookie.md +183 -0
  89. package/{3.api → 4.api}/2.composables/use-error.md +2 -2
  90. package/{3.api → 4.api}/2.composables/use-fetch.md +33 -33
  91. package/{3.api → 4.api}/2.composables/use-head.md +16 -1
  92. package/{3.api → 4.api}/2.composables/use-lazy-fetch.md +8 -8
  93. package/{3.api → 4.api}/2.composables/use-nuxt-app.md +6 -4
  94. package/{3.api → 4.api}/2.composables/use-response-header.md +1 -1
  95. package/{3.api → 4.api}/2.composables/use-route-announcer.md +0 -2
  96. package/{3.api → 4.api}/2.composables/use-route.md +1 -1
  97. package/{3.api → 4.api}/2.composables/use-router.md +2 -2
  98. package/{3.api → 4.api}/2.composables/use-runtime-config.md +1 -1
  99. package/{3.api → 4.api}/2.composables/use-state.md +10 -0
  100. package/{3.api → 4.api}/3.utils/$fetch.md +1 -1
  101. package/{3.api → 4.api}/3.utils/abort-navigation.md +1 -1
  102. package/{3.api → 4.api}/3.utils/add-route-middleware.md +1 -1
  103. package/{3.api → 4.api}/3.utils/call-once.md +0 -2
  104. package/{3.api → 4.api}/3.utils/create-error.md +6 -6
  105. package/{3.api → 4.api}/3.utils/define-nuxt-plugin.md +12 -12
  106. package/{3.api → 4.api}/3.utils/define-nuxt-route-middleware.md +2 -2
  107. package/{3.api → 4.api}/3.utils/define-page-meta.md +14 -7
  108. package/{3.api → 4.api}/3.utils/navigate-to.md +10 -10
  109. package/{3.api → 4.api}/3.utils/refresh-cookie.md +0 -2
  110. package/{3.api → 4.api}/3.utils/set-page-layout.md +36 -0
  111. package/{3.api → 4.api}/3.utils/set-response-status.md +2 -2
  112. package/{3.api → 4.api}/3.utils/show-error.md +3 -3
  113. package/{3.api → 4.api}/3.utils/update-app-config.md +2 -2
  114. package/{3.api → 4.api}/4.commands/add.md +11 -11
  115. package/4.api/4.commands/analyze.md +42 -0
  116. package/4.api/4.commands/build-module.md +42 -0
  117. package/4.api/4.commands/build.md +47 -0
  118. package/{3.api → 4.api}/4.commands/cleanup.md +6 -6
  119. package/4.api/4.commands/dev.md +60 -0
  120. package/{3.api → 4.api}/4.commands/devtools.md +7 -7
  121. package/4.api/4.commands/generate.md +42 -0
  122. package/4.api/4.commands/info.md +33 -0
  123. package/4.api/4.commands/init.md +50 -0
  124. package/4.api/4.commands/module.md +84 -0
  125. package/4.api/4.commands/prepare.md +41 -0
  126. package/4.api/4.commands/preview.md +44 -0
  127. package/4.api/4.commands/test.md +40 -0
  128. package/4.api/4.commands/typecheck.md +44 -0
  129. package/4.api/4.commands/upgrade.md +37 -0
  130. package/{3.api → 4.api}/5.kit/1.modules.md +30 -17
  131. package/{3.api → 4.api}/5.kit/10.templates.md +23 -23
  132. package/{3.api → 4.api}/5.kit/11.nitro.md +35 -35
  133. package/{3.api → 4.api}/5.kit/14.builder.md +29 -17
  134. package/{3.api → 4.api}/5.kit/16.layers.md +12 -12
  135. package/{3.api → 4.api}/5.kit/2.programmatic.md +2 -2
  136. package/{3.api → 4.api}/5.kit/4.autoimports.md +18 -18
  137. package/4.api/5.kit/5.components.md +146 -0
  138. package/4.api/6.advanced/1.hooks.md +105 -0
  139. package/{3.api → 4.api}/6.nuxt-config.md +7 -6
  140. package/5.community/4.contribution.md +5 -5
  141. package/5.community/5.framework-contribution.md +1 -1
  142. package/5.community/6.roadmap.md +25 -25
  143. package/5.community/7.changelog.md +20 -0
  144. package/6.bridge/1.overview.md +9 -1
  145. package/6.bridge/2.typescript.md +1 -1
  146. package/6.bridge/3.bridge-composition-api.md +1 -1
  147. package/6.bridge/4.plugins-and-middleware.md +3 -3
  148. package/6.bridge/8.nitro.md +4 -0
  149. package/7.migration/11.server.md +1 -1
  150. package/7.migration/2.configuration.md +4 -4
  151. package/7.migration/20.module-authors.md +3 -3
  152. package/7.migration/3.auto-imports.md +1 -1
  153. package/7.migration/5.plugins-and-middleware.md +2 -2
  154. package/7.migration/6.pages-and-layouts.md +6 -6
  155. package/7.migration/7.component-options.md +1 -1
  156. package/package.json +1 -1
  157. package/2.guide/3.going-further/3.modules.md +0 -968
  158. package/3.api/2.composables/use-cookie.md +0 -183
  159. package/3.api/4.commands/analyze.md +0 -42
  160. package/3.api/4.commands/build-module.md +0 -42
  161. package/3.api/4.commands/build.md +0 -47
  162. package/3.api/4.commands/dev.md +0 -60
  163. package/3.api/4.commands/generate.md +0 -42
  164. package/3.api/4.commands/info.md +0 -33
  165. package/3.api/4.commands/init.md +0 -50
  166. package/3.api/4.commands/module.md +0 -84
  167. package/3.api/4.commands/prepare.md +0 -41
  168. package/3.api/4.commands/preview.md +0 -44
  169. package/3.api/4.commands/test.md +0 -40
  170. package/3.api/4.commands/typecheck.md +0 -44
  171. package/3.api/4.commands/upgrade.md +0 -37
  172. package/3.api/5.kit/5.components.md +0 -146
  173. package/3.api/6.advanced/1.hooks.md +0 -105
  174. /package/{2.guide/1.directory-structure → 2.directory-structure}/.navigation.yml +0 -0
  175. /package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/.navigation.yml +0 -0
  176. /package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/3.app-config.md +0 -0
  177. /package/{2.guide/1.directory-structure → 2.directory-structure}/1.public.md +0 -0
  178. /package/{2.guide/1.directory-structure → 2.directory-structure}/2.gitignore.md +0 -0
  179. /package/{2.guide → 3.guide}/.navigation.yml +0 -0
  180. /package/{2.guide/2.concepts → 3.guide/1.concepts}/.navigation.yml +0 -0
  181. /package/{2.guide/2.concepts → 3.guide/1.concepts}/9.code-style.md +0 -0
  182. /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/.navigation.yml +0 -0
  183. /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/hydration.md +0 -0
  184. /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/plugins.md +0 -0
  185. /package/{2.guide/4.recipes → 3.guide/5.recipes}/.navigation.yml +0 -0
  186. /package/{2.guide/3.going-further → 3.guide/6.going-further}/.navigation.yml +0 -0
  187. /package/{2.guide/3.going-further → 3.guide/6.going-further}/1.features.md +0 -0
  188. /package/{2.guide/3.going-further → 3.guide/6.going-further}/11.nightly-release-channel.md +0 -0
  189. /package/{2.guide/3.going-further → 3.guide/6.going-further}/9.debugging.md +0 -0
  190. /package/{2.guide/3.going-further → 3.guide/6.going-further}/index.md +0 -0
  191. /package/{3.api → 4.api}/.navigation.yml +0 -0
  192. /package/{3.api → 4.api}/1.components/.navigation.yml +0 -0
  193. /package/{3.api → 4.api}/1.components/1.client-only.md +0 -0
  194. /package/{3.api → 4.api}/1.components/1.dev-only.md +0 -0
  195. /package/{3.api → 4.api}/1.components/10.nuxt-picture.md +0 -0
  196. /package/{3.api → 4.api}/1.components/11.teleports.md +0 -0
  197. /package/{3.api → 4.api}/1.components/4.nuxt-link.md +0 -0
  198. /package/{3.api → 4.api}/1.components/6.nuxt-error-boundary.md +0 -0
  199. /package/{3.api → 4.api}/1.components/9.nuxt-img.md +0 -0
  200. /package/{3.api → 4.api}/2.composables/.navigation.yml +0 -0
  201. /package/{3.api → 4.api}/2.composables/on-prehydrate.md +0 -0
  202. /package/{3.api → 4.api}/2.composables/use-head-safe.md +0 -0
  203. /package/{3.api → 4.api}/2.composables/use-hydration.md +0 -0
  204. /package/{3.api → 4.api}/2.composables/use-lazy-async-data.md +0 -0
  205. /package/{3.api → 4.api}/2.composables/use-loading-indicator.md +0 -0
  206. /package/{3.api → 4.api}/2.composables/use-nuxt-data.md +0 -0
  207. /package/{3.api → 4.api}/2.composables/use-preview-mode.md +0 -0
  208. /package/{3.api → 4.api}/2.composables/use-request-event.md +0 -0
  209. /package/{3.api → 4.api}/2.composables/use-request-fetch.md +0 -0
  210. /package/{3.api → 4.api}/2.composables/use-request-header.md +0 -0
  211. /package/{3.api → 4.api}/2.composables/use-request-headers.md +0 -0
  212. /package/{3.api → 4.api}/2.composables/use-request-url.md +0 -0
  213. /package/{3.api → 4.api}/2.composables/use-runtime-hook.md +0 -0
  214. /package/{3.api → 4.api}/2.composables/use-seo-meta.md +0 -0
  215. /package/{3.api → 4.api}/2.composables/use-server-seo-meta.md +0 -0
  216. /package/{3.api → 4.api}/3.utils/.navigation.yml +0 -0
  217. /package/{3.api → 4.api}/3.utils/clear-error.md +0 -0
  218. /package/{3.api → 4.api}/3.utils/clear-nuxt-data.md +0 -0
  219. /package/{3.api → 4.api}/3.utils/clear-nuxt-state.md +0 -0
  220. /package/{3.api → 4.api}/3.utils/define-lazy-hydration-component.md +0 -0
  221. /package/{3.api → 4.api}/3.utils/define-nuxt-component.md +0 -0
  222. /package/{3.api → 4.api}/3.utils/define-route-rules.md +0 -0
  223. /package/{3.api → 4.api}/3.utils/on-before-route-leave.md +0 -0
  224. /package/{3.api → 4.api}/3.utils/on-before-route-update.md +0 -0
  225. /package/{3.api → 4.api}/3.utils/on-nuxt-ready.md +0 -0
  226. /package/{3.api → 4.api}/3.utils/prefetch-components.md +0 -0
  227. /package/{3.api → 4.api}/3.utils/preload-components.md +0 -0
  228. /package/{3.api → 4.api}/3.utils/preload-route-components.md +0 -0
  229. /package/{3.api → 4.api}/3.utils/prerender-routes.md +0 -0
  230. /package/{3.api → 4.api}/3.utils/refresh-nuxt-data.md +0 -0
  231. /package/{3.api → 4.api}/3.utils/reload-nuxt-app.md +0 -0
  232. /package/{3.api → 4.api}/4.commands/.navigation.yml +0 -0
  233. /package/{3.api → 4.api}/5.kit/.navigation.yml +0 -0
  234. /package/{3.api → 4.api}/5.kit/10.runtime-config.md +0 -0
  235. /package/{3.api → 4.api}/5.kit/12.resolving.md +0 -0
  236. /package/{3.api → 4.api}/5.kit/13.logging.md +0 -0
  237. /package/{3.api → 4.api}/5.kit/15.examples.md +0 -0
  238. /package/{3.api → 4.api}/5.kit/3.compatibility.md +0 -0
  239. /package/{3.api → 4.api}/5.kit/6.context.md +0 -0
  240. /package/{3.api → 4.api}/5.kit/7.pages.md +0 -0
  241. /package/{3.api → 4.api}/5.kit/8.layout.md +0 -0
  242. /package/{3.api → 4.api}/5.kit/9.head.md +0 -0
  243. /package/{3.api → 4.api}/5.kit/9.plugins.md +0 -0
  244. /package/{3.api → 4.api}/6.advanced/.navigation.yml +0 -0
  245. /package/{3.api → 4.api}/6.advanced/2.import-meta.md +0 -0
  246. /package/{3.api → 4.api}/index.md +0 -0
@@ -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/guide/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/4.x/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
 
@@ -40,10 +40,10 @@ You can now use auto imported utility functions in `.js`, `.ts` and `.vue` files
40
40
  :link-example{to="/docs/4.x/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/guide/directory-structure/app/composables) directory.
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.
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/guide/directory-structure/server#server-utilities) directory.
48
+ Only `server/utils` are auto-imported in the [`server/`](/docs/4.x/directory-structure/server#server-utilities) directory.
49
49
  ::
@@ -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/guide/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/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.
17
17
 
18
18
  ```vue [app/app.vue]
19
19
  <template>
@@ -25,7 +25,7 @@ With Nuxt, the [`app/pages/`](/docs/4.x/guide/directory-structure/app/pages) dir
25
25
 
26
26
  ### Usage with Pages
27
27
 
28
- When you have a [`app/pages/`](/docs/4.x/guide/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/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:
29
29
 
30
30
  ```vue [app/app.vue]
31
31
  <template>
@@ -51,7 +51,7 @@ 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/guide/directory-structure/app/pages"}
54
+ ::read-more{to="/docs/4.x/directory-structure/app/pages"}
55
55
  Learn more about how to structure your pages using the `app/pages/` directory.
56
56
  ::
57
57
 
@@ -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/guide/directory-structure/app/layouts"}
70
+ ::read-more{to="/docs/4.x/directory-structure/app/layouts"}
71
71
  Learn more about how to structure your layouts using the `app/layouts/` directory.
72
72
  ::
@@ -11,14 +11,12 @@ During the lifespan of your application, some errors may appear unexpectedly at
11
11
  <script setup lang="ts">
12
12
  import type { NuxtError } from '#app'
13
13
 
14
- const props = defineProps({
15
- error: Object as () => NuxtError,
16
- })
14
+ const props = defineProps<{ error: NuxtError }>()
17
15
  </script>
18
16
 
19
17
  <template>
20
18
  <div>
21
- <h1>{{ error.statusCode }}</h1>
19
+ <h1>{{ error.status }}</h1>
22
20
  <NuxtLink to="/">Go back home</NuxtLink>
23
21
  </div>
24
22
  </template>
@@ -33,12 +31,16 @@ The error page has a single prop - `error` which contains an error for you to ha
33
31
  The `error` object provides the following fields:
34
32
  ```ts
35
33
  interface NuxtError {
36
- statusCode: number
34
+ status: number
37
35
  fatal: boolean
38
36
  unhandled: boolean
39
- statusMessage?: string
37
+ statusText?: string
40
38
  data?: unknown
41
39
  cause?: unknown
40
+ // legacy/deprecated equivalent of `status`
41
+ statusCode: number
42
+ // legacy/deprecated equivalent of `statusText`
43
+ statusMessage?: string
42
44
  }
43
45
  ```
44
46
 
@@ -46,8 +48,8 @@ If you have an error with custom fields they will be lost; you should assign the
46
48
 
47
49
  ```ts
48
50
  throw createError({
49
- statusCode: 404,
50
- statusMessage: 'Page Not Found',
51
+ status: 404,
52
+ statusText: 'Page Not Found',
51
53
  data: {
52
54
  myCustomField: true,
53
55
  },
@@ -5,7 +5,7 @@ description: Use the content/ directory to create a file-based CMS for your appl
5
5
  navigation.icon: i-vscode-icons-folder-type-log
6
6
  ---
7
7
 
8
- [Nuxt Content](https://content.nuxt.com) reads the [`content/` directory](/docs/4.x/guide/directory-structure/content) in your project and parses `.md`, `.yml`, `.csv` and `.json` files to create a file-based CMS for your application.
8
+ [Nuxt Content](https://content.nuxt.com) reads the `content/` directory in your project and parses `.md`, `.yml`, `.csv` and `.json` files to create a file-based CMS for your application.
9
9
 
10
10
  - Render your content with built-in components.
11
11
  - Query your content with a MongoDB-like API.
@@ -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/guide/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/4.x/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>
@@ -0,0 +1,87 @@
1
+ ---
2
+ title: 'layers'
3
+ head.title: 'layers/'
4
+ description: Use the layers/ directory to organize and auto-register local layers within your application.
5
+ navigation.icon: i-vscode-icons-folder-type-nuxt
6
+ ---
7
+
8
+ The `layers/` directory allows you to organize and share reusable code, components, composables, and configurations across your Nuxt application. Any layers within your project in the `layers/` directory will be automatically registered.
9
+
10
+ ::note
11
+ The `layers/` directory auto-registration is available in Nuxt v3.12.0+.
12
+ ::
13
+
14
+ ::tip{icon="i-lucide-lightbulb"}
15
+ Layers are ideal for organizing large codebases with **Domain-Driven Design (DDD)**, creating reusable **UI libraries** or **themes**, sharing **configuration presets** across projects, and separating concerns like **admin panels** or **feature modules**.
16
+ ::
17
+
18
+ ## Structure
19
+
20
+ Each subdirectory within `layers/` is treated as a separate layer. A layer can contain the same structure as a standard Nuxt application.
21
+
22
+ ::important
23
+ Every layer **must have** a `nuxt.config.ts` file to be recognized as a valid layer, even if it's empty.
24
+ ::
25
+
26
+ ```bash [Directory structure]
27
+ -| layers/
28
+ ---| base/
29
+ -----| nuxt.config.ts
30
+ -----| app/
31
+ -------| components/
32
+ ---------| BaseButton.vue
33
+ -------| composables/
34
+ ---------| useBase.ts
35
+ -----| server/
36
+ -------| api/
37
+ ---------| hello.ts
38
+ ---| admin/
39
+ -----| nuxt.config.ts
40
+ -----| app/
41
+ -------| pages/
42
+ ---------| admin.vue
43
+ -------| layouts/
44
+ ---------| admin.vue
45
+ ```
46
+
47
+ ## Automatic Aliases
48
+
49
+ Named layer aliases to the `srcDir` of each layer are automatically created. You can access a layer using the `#layers/[name]` alias:
50
+
51
+ ```ts
52
+ // Access the base layer
53
+ import something from '#layers/base/path/to/file'
54
+
55
+ // Access the admin layer
56
+ import { useAdmin } from '#layers/admin/composables/useAdmin'
57
+ ```
58
+
59
+ ::note
60
+ Named layer aliases were introduced in Nuxt v3.16.0.
61
+ ::
62
+
63
+ ## Layer Content
64
+
65
+ Each layer can include:
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
78
+
79
+ ## Priority Order
80
+
81
+ When multiple layers define the same resource (component, composable, page, etc.), the layer with **higher priority wins**. Layers are sorted alphabetically, with later letters having higher priority (Z > A).
82
+
83
+ To control the order, prefix directories with numbers: `1.base/`, `2.features/`, `3.admin/`.
84
+
85
+ :read-more{to="/docs/4.x/getting-started/layers#layer-priority"}
86
+
87
+ :video-accordion{title="Watch a video from Learn Vue about Nuxt Layers" videoId="lnFCM7c9f7I"}
@@ -11,14 +11,14 @@ 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/guide/directory-structure/nuxt-config) separately.
14
+ You don't need to add those local modules to your [`nuxt.config.ts`](/docs/4.x/directory-structure/nuxt-config) separately.
15
15
 
16
16
  ::code-group
17
17
 
18
18
  ```ts twoslash [modules/hello/index.ts]
19
19
  // `nuxt/kit` is a helper subpath import you can use when defining local modules
20
20
  // that means you do not need to add `@nuxt/kit` to your project's dependencies
21
- import { addServerHandler, createResolver, defineNuxtModule } from 'nuxt/kit'
21
+ import { addComponentsDir, addServerHandler, createResolver, defineNuxtModule } from 'nuxt/kit'
22
22
 
23
23
  export default defineNuxtModule({
24
24
  meta: {
@@ -32,6 +32,12 @@ export default defineNuxtModule({
32
32
  route: '/api/hello',
33
33
  handler: resolver.resolve('./runtime/api-route'),
34
34
  })
35
+
36
+ // Add components
37
+ addComponentsDir({
38
+ path: resolver.resolve('./runtime/app/components'),
39
+ pathPrefix: true, // Prefix your exports to avoid conflicts with user code or other modules
40
+ })
35
41
  },
36
42
  })
37
43
  ```
@@ -46,6 +52,10 @@ export default defineEventHandler(() => {
46
52
 
47
53
  When starting Nuxt, the `hello` module will be registered and the `/api/hello` route will be available.
48
54
 
55
+ ::note
56
+ Note that all components, pages, composables and other files that would be normally placed in your `app/` directory need to be in `modules/your-module/runtime/app/`. This ensures they can be type-checked properly.
57
+ ::
58
+
49
59
  Modules are executed in the following sequence:
50
60
  - First, the modules defined in [`nuxt.config.ts`](/docs/4.x/api/nuxt-config#modules-1) are loaded.
51
61
  - Then, modules found in the `modules/` directory are executed, and they load in alphabetical order.
@@ -59,7 +69,7 @@ modules/
59
69
  2.second-module.ts
60
70
  ```
61
71
 
62
- :read-more{to="/docs/4.x/guide/going-further/modules"}
72
+ :read-more{to="/docs/4.x/guide/modules"}
63
73
 
64
74
  ::tip{icon="i-lucide-video" to="https://vueschool.io/lessons/creating-your-first-module-from-scratch?friend=nuxt" target="_blank"}
65
75
  Watch Vue School video about Nuxt private modules.
@@ -5,8 +5,8 @@ head.title: "node_modules/"
5
5
  navigation.icon: i-vscode-icons-folder-type-node
6
6
  ---
7
7
 
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)) creates this directory to store the dependencies of your project.
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/guide/directory-structure/gitignore) file to avoid pushing the dependencies to your repository.
11
+ This directory should be added to your [`.gitignore`](/docs/4.x/directory-structure/gitignore) file to avoid pushing the dependencies to your repository.
12
12
  ::
@@ -58,7 +58,7 @@ export default defineEventHandler(() => 'Hello World!')
58
58
  Given the example above, the `/hello` route will be accessible at <http://localhost:3000/hello>.
59
59
 
60
60
  ::note
61
- Note that currently server routes do not support the full functionality of dynamic routes as [pages](/docs/4.x/guide/directory-structure/app/pages#dynamic-routes) do.
61
+ 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.
62
62
  ::
63
63
 
64
64
  ## Server Middleware
@@ -112,8 +112,6 @@ For example, you can define a custom handler utility that wraps the original han
112
112
  **Example:**
113
113
 
114
114
  ```ts [server/utils/handler.ts]
115
- import type { EventHandler, EventHandlerRequest } from 'h3'
116
-
117
115
  export const defineWrappedResponseHandler = <T extends EventHandlerRequest, D> (
118
116
  handler: EventHandler<T, D>,
119
117
  ): EventHandler<T, D> =>
@@ -130,11 +128,33 @@ export const defineWrappedResponseHandler = <T extends EventHandlerRequest, D> (
130
128
  })
131
129
  ```
132
130
 
131
+ ```ts [server/api/hello.get.ts]
132
+ export default defineWrappedResponseHandler(event => 'hello world')
133
+ ```
134
+
135
+ ## Server Alias
136
+
137
+ You can use the `#server` alias to import files from anywhere within the `server/` directory, regardless of the importing file's location.
138
+
139
+ ```ts [server/api/users/[id]/profile.ts]
140
+ // Instead of relative paths like this:
141
+ // import { formatUser } from '../../../utils/formatUser'
142
+
143
+ // Use the #server alias:
144
+ import { formatUser } from '#server/utils/formatUser'
145
+ ```
146
+
147
+ This alias ensures consistent imports across your server code, especially useful in deeply nested route handlers.
148
+
149
+ ::note
150
+ The `#server` alias can only be used within the `server/` directory. Importing from `#server` in client code will result in an error.
151
+ ::
152
+
133
153
  ## Server Types
134
154
 
135
155
  Auto-imports and other types are different for the `server/` directory, as it is running in a different context from the `app/` directory.
136
156
 
137
- By default, Nuxt 4 generates a [`tsconfig.json`](/docs/4.x/guide/directory-structure/tsconfig) which includes a project reference covering the `server/` folder which ensures accurate typings.
157
+ 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.
138
158
 
139
159
  ## Recipes
140
160
 
@@ -277,8 +297,8 @@ export default defineEventHandler((event) => {
277
297
 
278
298
  if (!Number.isInteger(id)) {
279
299
  throw createError({
280
- statusCode: 400,
281
- statusMessage: 'ID should be an integer',
300
+ status: 400,
301
+ statusText: 'ID should be an integer',
282
302
  })
283
303
  }
284
304
  return 'All good'
@@ -454,7 +474,7 @@ Never combine `next()` callback with a legacy middleware that is `async` or retu
454
474
 
455
475
  ### Server Storage
456
476
 
457
- 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/guide/directory-structure/server#server-plugins).
477
+ 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).
458
478
 
459
479
  **Example of adding a Redis storage:**
460
480
 
@@ -35,7 +35,7 @@ export default function (input: string) {
35
35
  }
36
36
  ```
37
37
 
38
- You can now use [auto-imported](/docs/4.x/guide/directory-structure/shared) utilities in your Nuxt app and `server/` directory.
38
+ You can now use [auto-imported](/docs/4.x/directory-structure/shared) utilities in your Nuxt app and `server/` directory.
39
39
 
40
40
  ```vue [app/app.vue]
41
41
  <script setup lang="ts">
@@ -62,10 +62,10 @@ export default defineEventHandler((event) => {
62
62
  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`.
63
63
 
64
64
  ::tip
65
- The way `shared/utils` and `shared/types` auto-imports work and are scanned is identical to the [`app/composables/`](/docs/4.x/guide/directory-structure/app/composables) and [`app/utils/`](/docs/4.x/guide/directory-structure/app/utils) directories.
65
+ 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.
66
66
  ::
67
67
 
68
- :read-more{to="/docs/4.x/guide/directory-structure/app/composables#how-files-are-scanned"}
68
+ :read-more{to="/docs/4.x/directory-structure/app/composables#how-files-are-scanned"}
69
69
 
70
70
  ```bash [Directory Structure]
71
71
  -| shared/
@@ -6,7 +6,7 @@ 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/guide/directory-structure/gitignore) file to avoid pushing secrets to your repository.
9
+ This file should be added to your [`.gitignore`](/docs/4.x/directory-structure/gitignore) file to avoid pushing secrets to your repository.
10
10
  ::
11
11
 
12
12
  ## Dev, Build and Generate Time
@@ -75,5 +75,5 @@ Note that for a purely static site, it is not possible to set runtime configurat
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/guide/directory-structure/app/app-config"}
78
+ :read-more{to="/docs/4.x/directory-structure/app/app-config"}
79
79
  ::
@@ -8,7 +8,7 @@ navigation.icon: i-vscode-icons-file-type-nuxt
8
8
 
9
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.
10
10
 
11
- It is subject to the same specification as [`.gitignore`](/docs/4.x/guide/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/4.x/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
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.
@@ -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/guide/directory-structure/nuxt-config).
11
+ For more advanced configurations, use [`nuxt.config`](/docs/4.x/directory-structure/nuxt-config).
12
12
  ::
13
13
 
14
14
  ## Usage
@@ -23,6 +23,9 @@ devtools.enabled=true
23
23
  # Add Nuxt modules
24
24
  modules[]=@nuxt/image
25
25
  modules[]=nuxt-security
26
+
27
+ # Module setups (automatically added by Nuxt)
28
+ setups.@nuxt/test-utils="3.23.0"
26
29
  ```
27
30
 
28
31
  If present, the properties in the `nuxt.config` file will overwrite the properties in `.nuxtrc` file.
@@ -31,4 +31,4 @@ export default defineNuxtConfig({
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/guide/directory-structure/env), [`.nuxtignore`](/docs/4.x/guide/directory-structure/nuxtignore) and [`.nuxtrc`](/docs/4.x/guide/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/4.x/directory-structure/env), [`.nuxtignore`](/docs/4.x/directory-structure/nuxtignore) and [`.nuxtrc`](/docs/4.x/directory-structure/nuxtrc) dotfiles.
@@ -27,6 +27,6 @@ The minimal `package.json` of your Nuxt application should looks like:
27
27
  }
28
28
  ```
29
29
 
30
- ::read-more{icon="i-simple-icons-npm" to="https://docs.npmjs.com/cli/configuring-npm/package-json" target="_blank"}
30
+ ::read-more{icon="i-simple-icons-npm" to="https://docs.npmjs.com/cli/configuring-npm/package-json/" target="_blank"}
31
31
  Read more about the `package.json` file.
32
32
  ::
@@ -42,6 +42,7 @@ Read more about the different type contexts of a Nuxt project here.
42
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.
43
43
  <!-- @case-police-ignore tsConfig -->
44
44
  ```ts twoslash [nuxt.config.ts]
45
+ // @errors: 2353
45
46
  export default defineNuxtConfig({
46
47
  typescript: {
47
48
  // customize tsconfig.app.json
@@ -0,0 +1,65 @@
1
+ ---
2
+ title: 'Nuxt Directory Structure'
3
+ description: 'Learn about the directory structure of a Nuxt application and how to use it.'
4
+ navigation: false
5
+ ---
6
+
7
+ Nuxt applications have a specific directory structure that is used to organize the code. This structure is designed to be easy to understand and to be used in a consistent way.
8
+
9
+ ## Root Directory
10
+
11
+ The root directory of a Nuxt application is the directory that contains the `nuxt.config.ts` file. This file is used to configure the Nuxt application.
12
+
13
+ ## App Directory
14
+
15
+ The `app/` directory is the main directory of the Nuxt application. It contains the following subdirectories:
16
+ - [`assets/`](/docs/4.x/directory-structure/app/assets): website's assets that the build tool (Vite or webpack) will process
17
+ - [`components/`](/docs/4.x/directory-structure/app/components): Vue components of the application
18
+ - [`composables/`](/docs/4.x/directory-structure/app/composables): add your Vue composables
19
+ - [`layouts/`](/docs/4.x/directory-structure/app/layouts): Vue components that wrap around your pages and avoid re-rendering between pages
20
+ - [`middleware/`](/docs/4.x/directory-structure/app/middleware): run code before navigating to a particular route
21
+ - [`pages/`](/docs/4.x/directory-structure/app/pages): file-based routing to create routes within your web application
22
+ - [`plugins/`](/docs/4.x/directory-structure/app/plugins): use Vue plugins and more at the creation of your Nuxt application
23
+ - [`utils/`](/docs/4.x/directory-structure/app/utils): add functions throughout your application that can be used in your components, composables, and pages.
24
+
25
+ This directory also includes specific files:
26
+ - [`app.config.ts`](/docs/4.x/directory-structure/app/app-config): a reactive configuration within your application
27
+ - [`app.vue`](/docs/4.x/directory-structure/app/app): the root component of your Nuxt application
28
+ - [`error.vue`](/docs/4.x/directory-structure/app/error): the error page of your Nuxt application
29
+
30
+ ## Public Directory
31
+
32
+ The [`public/`](/docs/4.x/directory-structure/public) directory is the directory that contains the public files of the Nuxt application. Files contained within this directory are served at the root and are not modified by the build process.
33
+
34
+ This is suitable for files that have to keep their names (e.g. `robots.txt`) _or_ likely won't change (e.g. `favicon.ico`).
35
+
36
+ ## Server Directory
37
+
38
+ The [`server/`](/docs/4.x/directory-structure/server) directory is the directory that contains the server-side code of the Nuxt application. It contains the following subdirectories:
39
+ - [`api/`](/docs/4.x/directory-structure/server#server-routes): contains the API routes of the application.
40
+ - [`routes/`](/docs/4.x/directory-structure/server#server-routes): contains the server routes of the application (e.g. dynamic `/sitemap.xml`).
41
+ - [`middleware/`](/docs/4.x/directory-structure/server#server-middleware): run code before a server route is processed
42
+ - [`plugins/`](/docs/4.x/directory-structure/server#server-plugins): use plugins and more at the creation of the Nuxt server
43
+ - [`utils/`](/docs/4.x/directory-structure/server#server-utilities): add functions throughout your application that can be used in your server code.
44
+
45
+ ## Shared Directory
46
+
47
+ The [`shared/`](/docs/4.x/directory-structure/shared) directory is the directory that contains the shared code of the Nuxt application and Nuxt server. This code can be used in both the Vue app and the Nitro server.
48
+
49
+ ## Content Directory
50
+
51
+ The [`content/`](/docs/4.x/directory-structure/content) directory is enabled by the [Nuxt Content](https://content.nuxt.com) module. It is used to create a file-based CMS for your application using Markdown files.
52
+
53
+ ## Modules Directory
54
+
55
+ The [`modules/`](/docs/4.x/directory-structure/modules) directory is the directory that contains the local modules of the Nuxt application. Modules are used to extend the functionality of the Nuxt application.
56
+
57
+ ## Layers Directory
58
+
59
+ The [`layers/`](/docs/4.x/directory-structure/layers) directory allows you to organize and share reusable code, components, composables, and configurations. Layers within this directory are automatically registered in your project.
60
+
61
+ ## Nuxt Files
62
+
63
+ - [`nuxt.config.ts`](/docs/4.x/directory-structure/nuxt-config) file is the main configuration file for the Nuxt application.
64
+ - [`.nuxtrc`](/docs/4.x/directory-structure/nuxtrc) file is another syntax for configuring the Nuxt application (useful for global configurations).
65
+ - [`.nuxtignore`](/docs/4.x/directory-structure/nuxtignore) file is used to ignore files in the root directory during the build phase.
@@ -7,19 +7,22 @@ surround: false
7
7
  ---
8
8
 
9
9
  ::card-group{class="sm:grid-cols-1"}
10
- ::card{icon="i-lucide-folders" title="Directory Structure" to="/docs/4.x/guide/directory-structure"}
11
- Learn about Nuxt directory structure and what benefits each directory or file offers.
12
- ::
13
10
  ::card{icon="i-lucide-medal" title="Key Concepts" to="/docs/4.x/guide/concepts"}
14
11
  Discover the main concepts behind Nuxt, from auto-import, hybrid rendering to its TypeScript support.
15
12
  ::
16
- ::card{icon="i-lucide-star" title="Going Further" to="/docs/4.x/guide/going-further"}
17
- Master Nuxt with advanced concepts like experimental features, hooks, modules, and more.
13
+ ::card{icon="i-lucide-square-check" title="Best Practices" to="/docs/4.x/guide/best-practices"}
14
+ Learn about best practices when developing with Nuxt.
15
+ ::
16
+ ::card{icon="i-lucide-bot" title="Working with AI" to="/docs/4.x/guide/ai"}
17
+ Integrate AI tools into your Nuxt workflow with MCP Server and LLMs.txt.
18
+ ::
19
+ ::card{icon="i-lucide-box" title="Module Author Guide" to="/docs/4.x/guide/modules"}
20
+ Learn how to create Nuxt modules to integrate, enhance or extend any Nuxt application.
18
21
  ::
19
22
  ::card{icon="i-lucide-book-open" title="Recipes" to="/docs/4.x/guide/recipes"}
20
23
  Find solutions to common problems and learn how to implement them in your Nuxt project.
21
24
  ::
22
- ::card{icon="i-lucide-square-check" title="Best Practices" to="/docs/4.x/guide/best-practices"}
23
- Learn about best practices when developing with Nuxt
25
+ ::card{icon="i-lucide-star" title="Going Further" to="/docs/4.x/guide/going-further"}
26
+ Master Nuxt with advanced concepts like experimental features, hooks, and more.
24
27
  ::
25
28
  ::
@@ -44,7 +44,7 @@ const handleClick = () => {
44
44
 
45
45
  On the initial request, the `counter` ref is initialized in the server since it is rendered inside the `<p>` tag. The contents of `handleClick` is never executed here. During hydration in the browser, the `counter` ref is re-initialized. The `handleClick` finally binds itself to the button; Therefore it is reasonable to deduce that the body of `handleClick` will always run in a browser environment.
46
46
 
47
- [Middlewares](/docs/4.x/guide/directory-structure/app/middleware) and [pages](/docs/4.x/guide/directory-structure/app/pages) run in the server and on the client during hydration. [Plugins](/docs/4.x/guide/directory-structure/app/plugins) can be rendered on the server or client or both. [Components](/docs/4.x/guide/directory-structure/app/components) can be forced to run on the client only as well. [Composables](/docs/4.x/guide/directory-structure/app/composables) and [utilities](/docs/4.x/guide/directory-structure/app/utils) are rendered based on the context of their usage.
47
+ [Middlewares](/docs/4.x/directory-structure/app/middleware) and [pages](/docs/4.x/directory-structure/app/pages) run in the server and on the client during hydration. [Plugins](/docs/4.x/directory-structure/app/plugins) can be rendered on the server or client or both. [Components](/docs/4.x/directory-structure/app/components) can be forced to run on the client only as well. [Composables](/docs/4.x/directory-structure/app/composables) and [utilities](/docs/4.x/directory-structure/app/utils) are rendered based on the context of their usage.
48
48
 
49
49
  **Benefits of server-side rendering:**
50
50
  - **Performance**: Users can get immediate access to the page's content because browsers can display static content much faster than JavaScript-generated content. At the same time, Nuxt preserves the interactivity of a web application during the hydration process.
@@ -131,6 +131,7 @@ The `200.html` and `404.html` might be useful for the hosting provider you are u
131
131
  When prerendering a client-rendered app, Nuxt will generate `index.html`, `200.html` and `404.html` files by default. However, if you need to prevent any (or all) of these files from being generated in your build, you can use the `'prerender:generate'` hook from [Nitro](/docs/4.x/getting-started/prerendering#prerendergenerate-nitro-hook).
132
132
 
133
133
  ```ts twoslash [nuxt.config.ts]
134
+ // @errors: 2353 7006
134
135
  export default defineNuxtConfig({
135
136
  ssr: false,
136
137
  nitro: {
@@ -229,29 +230,3 @@ The current platforms where you can leverage ESR are:
229
230
  - [Netlify Edge Functions](https://www.netlify.com/platform/#netlify-edge-functions) using the `nuxt build` command and `NITRO_PRESET=netlify-edge` environment variable
230
231
 
231
232
  Note that **Hybrid Rendering** can be used when using Edge-Side Rendering with route rules.
232
-
233
- You can explore open source examples deployed on some of the platform mentioned above:
234
- ::card-group
235
- ::card
236
- ---
237
- icon: i-simple-icons-github
238
- title: Nuxt Todos Edge
239
- to: https://github.com/atinux/nuxt-todos-edge
240
- target: _blank
241
- ui.icon.base: text-black dark:text-white
242
- ---
243
- A todos application with user authentication, SSR and SQLite.
244
- ::
245
- ::card
246
- ---
247
- icon: i-simple-icons-github
248
- title: Atinotes
249
- to: https://github.com/atinux/atinotes
250
- target: _blank
251
- ui.icon.base: text-black dark:text-white
252
- ---
253
- An editable website with universal rendering based on Cloudflare KV.
254
- ::
255
- ::
256
-
257
- <!-- TODO: link to templates with ESR category for examples -->
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: 'Vue.js Development'
3
3
  description: "Nuxt uses Vue.js and adds features such as component auto-imports, file-based routing and composables for an SSR-friendly usage."
4
+ navigation: false
4
5
  ---
5
6
 
6
7
  Nuxt integrates Vue 3, the new major release of Vue that enables new patterns for Nuxt users.
@@ -25,13 +26,13 @@ We chose to build Nuxt on top of Vue for these reasons:
25
26
 
26
27
  ### Auto-imports
27
28
 
28
- Every Vue component created in the [`app/components/`](/docs/4.x/guide/directory-structure/app/components) directory of a Nuxt project will be available in your project without having to import it. If a component is not used anywhere, your production’s code will not include it.
29
+ Every Vue component created in the [`app/components/`](/docs/4.x/directory-structure/app/components) directory of a Nuxt project will be available in your project without having to import it. If a component is not used anywhere, your production’s code will not include it.
29
30
 
30
31
  :read-more{to="/docs/4.x/guide/concepts/auto-imports"}
31
32
 
32
33
  ### Vue Router
33
34
 
34
- Most applications need multiple pages and a way to navigate between them. This is called **routing**. Nuxt uses an [`app/pages/`](/docs/4.x/guide/directory-structure/app/pages) directory and naming conventions to directly create routes mapped to your files using the official [Vue Router library](https://router.vuejs.org).
35
+ Most applications need multiple pages and a way to navigate between them. This is called **routing**. Nuxt uses an [`app/pages/`](/docs/4.x/directory-structure/app/pages) directory and naming conventions to directly create routes mapped to your files using the official [Vue Router library](https://router.vuejs.org).
35
36
 
36
37
  :read-more{to="/docs/4.x/getting-started/routing"}
37
38
 
@@ -92,7 +93,7 @@ const increment = () => count.value++
92
93
  The goal of Nuxt is to provide a great developer experience around the Composition API.
93
94
 
94
95
  - Use auto-imported [Reactivity functions](https://vuejs.org/api/reactivity-core) from Vue and Nuxt [built-in composables](/docs/4.x/api/composables/use-async-data).
95
- - Write your own auto-imported reusable functions in the [`app/composables/` directory](/docs/4.x/guide/directory-structure/app/composables).
96
+ - Write your own auto-imported reusable functions in the [`app/composables/` directory](/docs/4.x/directory-structure/app/composables).
96
97
 
97
98
  ### TypeScript Support
98
99