@nuxt/docs 4.1.1 → 4.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/1.getting-started/01.introduction.md +6 -6
  2. package/1.getting-started/02.installation.md +2 -1
  3. package/1.getting-started/03.configuration.md +37 -37
  4. package/1.getting-started/04.views.md +9 -9
  5. package/1.getting-started/05.assets.md +15 -9
  6. package/1.getting-started/06.styling.md +58 -48
  7. package/1.getting-started/07.routing.md +17 -17
  8. package/1.getting-started/08.seo-meta.md +59 -46
  9. package/1.getting-started/09.transitions.md +49 -44
  10. package/1.getting-started/10.data-fetching.md +104 -81
  11. package/1.getting-started/11.state-management.md +27 -20
  12. package/1.getting-started/12.error-handling.md +22 -20
  13. package/1.getting-started/13.server.md +8 -8
  14. package/1.getting-started/14.layers.md +22 -16
  15. package/1.getting-started/15.prerendering.md +32 -32
  16. package/1.getting-started/16.deployment.md +10 -10
  17. package/1.getting-started/17.testing.md +44 -44
  18. package/1.getting-started/18.upgrade.md +53 -71
  19. package/2.guide/0.index.md +7 -7
  20. package/2.guide/{2.directory-structure → 1.directory-structure}/.navigation.yml +1 -1
  21. package/2.guide/{2.directory-structure → 1.directory-structure}/0.nuxt.md +3 -3
  22. package/2.guide/1.directory-structure/0.output.md +18 -0
  23. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/.navigation.yml +1 -1
  24. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.assets.md +4 -4
  25. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.components.md +49 -28
  26. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.composables.md +13 -13
  27. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.layouts.md +19 -15
  28. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.middleware.md +31 -25
  29. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.pages.md +39 -37
  30. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.plugins.md +25 -25
  31. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.utils.md +7 -7
  32. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/3.app-config.md +18 -18
  33. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/3.app.md +7 -7
  34. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/3.error.md +6 -6
  35. package/2.guide/{2.directory-structure → 1.directory-structure}/1.content.md +7 -4
  36. package/2.guide/{2.directory-structure → 1.directory-structure}/1.modules.md +8 -8
  37. package/2.guide/{2.directory-structure → 1.directory-structure}/1.node_modules.md +2 -2
  38. package/2.guide/{2.directory-structure → 1.directory-structure}/1.public.md +2 -2
  39. package/2.guide/{2.directory-structure → 1.directory-structure}/1.server.md +35 -35
  40. package/2.guide/{2.directory-structure → 1.directory-structure}/1.shared.md +7 -7
  41. package/2.guide/{2.directory-structure → 1.directory-structure}/2.env.md +8 -8
  42. package/2.guide/{2.directory-structure → 1.directory-structure}/2.gitignore.md +1 -1
  43. package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtignore.md +5 -4
  44. package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtrc.md +4 -4
  45. package/2.guide/{2.directory-structure → 1.directory-structure}/3.nuxt-config.md +3 -3
  46. package/2.guide/{2.directory-structure → 1.directory-structure}/3.package.md +1 -1
  47. package/2.guide/{2.directory-structure → 1.directory-structure}/3.tsconfig.md +3 -3
  48. package/2.guide/{1.concepts → 2.concepts}/1.auto-imports.md +22 -22
  49. package/2.guide/{1.concepts → 2.concepts}/10.nuxt-lifecycle.md +17 -17
  50. package/2.guide/{1.concepts → 2.concepts}/2.vuejs-development.md +13 -13
  51. package/2.guide/{1.concepts → 2.concepts}/3.rendering.md +24 -22
  52. package/2.guide/{1.concepts → 2.concepts}/4.server-engine.md +6 -6
  53. package/2.guide/{1.concepts → 2.concepts}/5.modules.md +5 -5
  54. package/2.guide/{1.concepts → 2.concepts}/7.esm.md +17 -15
  55. package/2.guide/{1.concepts → 2.concepts}/8.typescript.md +12 -12
  56. package/2.guide/3.going-further/1.events.md +3 -3
  57. package/2.guide/3.going-further/1.experimental-features.md +246 -85
  58. package/2.guide/3.going-further/1.features.md +44 -9
  59. package/2.guide/3.going-further/1.internals.md +25 -25
  60. package/2.guide/3.going-further/10.runtime-config.md +12 -12
  61. package/2.guide/3.going-further/11.nightly-release-channel.md +1 -1
  62. package/2.guide/3.going-further/2.hooks.md +14 -14
  63. package/2.guide/3.going-further/3.modules.md +96 -94
  64. package/2.guide/3.going-further/4.kit.md +7 -7
  65. package/2.guide/3.going-further/6.nuxt-app.md +8 -8
  66. package/2.guide/3.going-further/7.layers.md +62 -53
  67. package/2.guide/3.going-further/9.debugging.md +2 -2
  68. package/2.guide/4.recipes/1.custom-routing.md +30 -30
  69. package/2.guide/4.recipes/2.vite-plugin.md +4 -4
  70. package/2.guide/4.recipes/3.custom-usefetch.md +13 -13
  71. package/2.guide/4.recipes/4.sessions-and-authentication.md +35 -21
  72. package/2.guide/5.best-practices/hydration.md +4 -4
  73. package/2.guide/5.best-practices/performance.md +17 -17
  74. package/3.api/1.components/1.client-only.md +6 -3
  75. package/3.api/1.components/1.nuxt-client-fallback.md +10 -7
  76. package/3.api/1.components/10.nuxt-picture.md +1 -1
  77. package/3.api/1.components/11.teleports.md +5 -2
  78. package/3.api/1.components/12.nuxt-route-announcer.md +9 -9
  79. package/3.api/1.components/13.nuxt-time.md +44 -17
  80. package/3.api/1.components/2.nuxt-page.md +6 -6
  81. package/3.api/1.components/3.nuxt-layout.md +15 -10
  82. package/3.api/1.components/4.nuxt-link.md +42 -22
  83. package/3.api/1.components/5.nuxt-loading-indicator.md +3 -3
  84. package/3.api/1.components/6.nuxt-error-boundary.md +12 -10
  85. package/3.api/2.composables/on-prehydrate.md +2 -2
  86. package/3.api/2.composables/use-app-config.md +1 -1
  87. package/3.api/2.composables/use-async-data.md +20 -20
  88. package/3.api/2.composables/use-cookie.md +29 -21
  89. package/3.api/2.composables/use-error.md +2 -2
  90. package/3.api/2.composables/use-fetch.md +58 -32
  91. package/3.api/2.composables/use-head-safe.md +7 -7
  92. package/3.api/2.composables/use-head.md +5 -5
  93. package/3.api/2.composables/use-hydration.md +6 -6
  94. package/3.api/2.composables/use-lazy-async-data.md +4 -4
  95. package/3.api/2.composables/use-lazy-fetch.md +4 -4
  96. package/3.api/2.composables/use-loading-indicator.md +12 -12
  97. package/3.api/2.composables/use-nuxt-app.md +22 -22
  98. package/3.api/2.composables/use-nuxt-data.md +8 -8
  99. package/3.api/2.composables/use-preview-mode.md +15 -18
  100. package/3.api/2.composables/use-request-event.md +1 -1
  101. package/3.api/2.composables/use-request-fetch.md +3 -3
  102. package/3.api/2.composables/use-request-header.md +1 -1
  103. package/3.api/2.composables/use-request-headers.md +4 -4
  104. package/3.api/2.composables/use-request-url.md +1 -1
  105. package/3.api/2.composables/use-response-header.md +9 -10
  106. package/3.api/2.composables/use-route-announcer.md +4 -4
  107. package/3.api/2.composables/use-route.md +1 -1
  108. package/3.api/2.composables/use-router.md +10 -8
  109. package/3.api/2.composables/use-runtime-config.md +11 -11
  110. package/3.api/2.composables/use-runtime-hook.md +2 -2
  111. package/3.api/2.composables/use-seo-meta.md +4 -4
  112. package/3.api/2.composables/use-server-seo-meta.md +6 -6
  113. package/3.api/2.composables/use-state.md +5 -5
  114. package/3.api/3.utils/$fetch.md +10 -8
  115. package/3.api/3.utils/abort-navigation.md +3 -3
  116. package/3.api/3.utils/add-route-middleware.md +5 -5
  117. package/3.api/3.utils/call-once.md +6 -6
  118. package/3.api/3.utils/clear-error.md +3 -3
  119. package/3.api/3.utils/clear-nuxt-data.md +3 -3
  120. package/3.api/3.utils/clear-nuxt-state.md +3 -3
  121. package/3.api/3.utils/create-error.md +2 -2
  122. package/3.api/3.utils/define-lazy-hydration-component.md +13 -13
  123. package/3.api/3.utils/define-nuxt-component.md +5 -5
  124. package/3.api/3.utils/define-nuxt-plugin.md +13 -13
  125. package/3.api/3.utils/define-nuxt-route-middleware.md +5 -5
  126. package/3.api/3.utils/define-page-meta.md +23 -23
  127. package/3.api/3.utils/define-route-rules.md +7 -7
  128. package/3.api/3.utils/navigate-to.md +11 -11
  129. package/3.api/3.utils/prefetch-components.md +1 -1
  130. package/3.api/3.utils/preload-components.md +1 -1
  131. package/3.api/3.utils/preload-route-components.md +2 -2
  132. package/3.api/3.utils/prerender-routes.md +3 -3
  133. package/3.api/3.utils/refresh-cookie.md +4 -4
  134. package/3.api/3.utils/refresh-nuxt-data.md +12 -7
  135. package/3.api/3.utils/reload-nuxt-app.md +3 -3
  136. package/3.api/3.utils/set-page-layout.md +1 -1
  137. package/3.api/3.utils/set-response-status.md +3 -3
  138. package/3.api/3.utils/show-error.md +5 -5
  139. package/3.api/3.utils/update-app-config.md +4 -3
  140. package/3.api/4.commands/add.md +1 -1
  141. package/3.api/4.commands/analyze.md +2 -1
  142. package/3.api/4.commands/build.md +2 -1
  143. package/3.api/4.commands/dev.md +5 -4
  144. package/3.api/4.commands/generate.md +3 -2
  145. package/3.api/4.commands/init.md +3 -2
  146. package/3.api/4.commands/module.md +4 -4
  147. package/3.api/4.commands/prepare.md +7 -2
  148. package/3.api/4.commands/preview.md +5 -4
  149. package/3.api/4.commands/test.md +40 -0
  150. package/3.api/4.commands/typecheck.md +5 -3
  151. package/3.api/4.commands/upgrade.md +3 -3
  152. package/3.api/5.kit/1.modules.md +36 -36
  153. package/3.api/5.kit/10.runtime-config.md +1 -1
  154. package/3.api/5.kit/10.templates.md +8 -6
  155. package/3.api/5.kit/11.nitro.md +62 -62
  156. package/3.api/5.kit/12.resolving.md +2 -2
  157. package/3.api/5.kit/14.builder.md +1 -0
  158. package/3.api/5.kit/15.examples.md +2 -2
  159. package/3.api/5.kit/16.layers.md +26 -26
  160. package/3.api/5.kit/3.compatibility.md +14 -14
  161. package/3.api/5.kit/4.autoimports.md +13 -13
  162. package/3.api/5.kit/5.components.md +7 -8
  163. package/3.api/5.kit/6.context.md +3 -3
  164. package/3.api/5.kit/7.pages.md +7 -7
  165. package/3.api/5.kit/8.layout.md +2 -2
  166. package/3.api/5.kit/9.plugins.md +5 -4
  167. package/3.api/6.advanced/1.hooks.md +3 -3
  168. package/3.api/6.advanced/2.import-meta.md +3 -3
  169. package/3.api/6.nuxt-config.md +300 -865
  170. package/3.api/index.md +7 -7
  171. package/5.community/2.getting-help.md +1 -1
  172. package/5.community/3.reporting-bugs.md +1 -1
  173. package/5.community/4.contribution.md +11 -11
  174. package/5.community/5.framework-contribution.md +4 -4
  175. package/5.community/6.roadmap.md +1 -1
  176. package/6.bridge/1.overview.md +13 -13
  177. package/6.bridge/10.configuration.md +2 -1
  178. package/6.bridge/2.typescript.md +3 -3
  179. package/6.bridge/3.bridge-composition-api.md +8 -8
  180. package/6.bridge/4.plugins-and-middleware.md +9 -9
  181. package/6.bridge/5.nuxt3-compatible-api.md +20 -17
  182. package/6.bridge/6.meta.md +21 -20
  183. package/6.bridge/7.runtime-config.md +1 -1
  184. package/6.bridge/8.nitro.md +3 -3
  185. package/6.bridge/9.vite.md +4 -4
  186. package/7.migration/1.overview.md +2 -2
  187. package/7.migration/10.bundling.md +1 -1
  188. package/7.migration/11.server.md +3 -3
  189. package/7.migration/2.configuration.md +23 -21
  190. package/7.migration/20.module-authors.md +7 -7
  191. package/7.migration/3.auto-imports.md +3 -3
  192. package/7.migration/4.meta.md +21 -18
  193. package/7.migration/5.plugins-and-middleware.md +8 -8
  194. package/7.migration/6.pages-and-layouts.md +28 -24
  195. package/7.migration/7.component-options.md +18 -18
  196. package/7.migration/8.runtime-config.md +7 -7
  197. package/package.json +1 -1
  198. package/2.guide/2.directory-structure/0.output.md +0 -18
  199. /package/2.guide/{1.concepts → 2.concepts}/.navigation.yml +0 -0
  200. /package/2.guide/{1.concepts → 2.concepts}/9.code-style.md +0 -0
@@ -2,10 +2,10 @@
2
2
  title: 'content'
3
3
  head.title: 'content/'
4
4
  description: Use the content/ directory to create a file-based CMS for your application.
5
- navigation.icon: i-lucide-folder
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/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](/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.
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/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/guide/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>
@@ -50,7 +50,10 @@ const { data: page } = await useAsyncData(route.path, () => {
50
50
  <div>
51
51
  <header><!-- ... --></header>
52
52
 
53
- <ContentRenderer v-if="page" :value="page" />
53
+ <ContentRenderer
54
+ v-if="page"
55
+ :value="page"
56
+ />
54
57
 
55
58
  <footer><!-- ... --></footer>
56
59
  </div>
@@ -2,7 +2,7 @@
2
2
  title: 'modules'
3
3
  head.title: 'modules/'
4
4
  description: Use the modules/ directory to automatically register local modules within your application.
5
- navigation.icon: i-lucide-folder
5
+ navigation.icon: i-vscode-icons-folder-type-nuxt
6
6
  ---
7
7
 
8
8
  It is a good place to place any local modules you develop while building your application.
@@ -11,18 +11,18 @@ 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/guide/directory-structure/nuxt-config) separately.
14
+ You don't need to add those local modules to your [`nuxt.config.ts`](/docs/4.x/guide/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 { createResolver, defineNuxtModule, addServerHandler } from 'nuxt/kit'
21
+ import { addServerHandler, createResolver, defineNuxtModule } from 'nuxt/kit'
22
22
 
23
23
  export default defineNuxtModule({
24
24
  meta: {
25
- name: 'hello'
25
+ name: 'hello',
26
26
  },
27
27
  setup () {
28
28
  const resolver = createResolver(import.meta.url)
@@ -30,9 +30,9 @@ export default defineNuxtModule({
30
30
  // Add an API route
31
31
  addServerHandler({
32
32
  route: '/api/hello',
33
- handler: resolver.resolve('./runtime/api-route')
33
+ handler: resolver.resolve('./runtime/api-route'),
34
34
  })
35
- }
35
+ },
36
36
  })
37
37
  ```
38
38
 
@@ -47,7 +47,7 @@ export default defineEventHandler(() => {
47
47
  When starting Nuxt, the `hello` module will be registered and the `/api/hello` route will be available.
48
48
 
49
49
  Modules are executed in the following sequence:
50
- - First, the modules defined in [`nuxt.config.ts`](/docs/api/nuxt-config#modules-1) are loaded.
50
+ - First, the modules defined in [`nuxt.config.ts`](/docs/4.x/api/nuxt-config#modules-1) are loaded.
51
51
  - Then, modules found in the `modules/` directory are executed, and they load in alphabetical order.
52
52
 
53
53
  You can change the order of local module by adding a number to the front of each directory name:
@@ -59,7 +59,7 @@ modules/
59
59
  2.second-module.ts
60
60
  ```
61
61
 
62
- :read-more{to="/docs/guide/going-further/modules"}
62
+ :read-more{to="/docs/4.x/guide/going-further/modules"}
63
63
 
64
64
  ::tip{icon="i-lucide-video" to="https://vueschool.io/lessons/creating-your-first-module-from-scratch?friend=nuxt" target="_blank"}
65
65
  Watch Vue School video about Nuxt private modules.
@@ -2,11 +2,11 @@
2
2
  title: "node_modules"
3
3
  description: "The package manager stores the dependencies of your project in the node_modules/ directory."
4
4
  head.title: "node_modules/"
5
- navigation.icon: i-lucide-folder
5
+ navigation.icon: i-vscode-icons-folder-type-node
6
6
  ---
7
7
 
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.sh/package-manager)) 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/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/guide/directory-structure/gitignore) file to avoid pushing the dependencies to your repository.
12
12
  ::
@@ -2,7 +2,7 @@
2
2
  title: "public"
3
3
  description: "The public/ directory is used to serve your website's static assets."
4
4
  head.title: "public/"
5
- navigation.icon: i-lucide-folder
5
+ navigation.icon: i-vscode-icons-folder-type-public
6
6
  ---
7
7
 
8
8
  Files contained within the `public/` directory are served at the root and are not modified by the build process. This is suitable for files that have to keep their names (e.g. `robots.txt`) _or_ likely won't change (e.g. `favicon.ico`).
@@ -17,7 +17,7 @@ Files contained within the `public/` directory are served at the root and are no
17
17
  ```vue [app/app.vue]
18
18
  <script setup lang="ts">
19
19
  useSeoMeta({
20
- ogImage: '/og-image.png'
20
+ ogImage: '/og-image.png',
21
21
  })
22
22
  </script>
23
23
  ```
@@ -2,7 +2,7 @@
2
2
  title: server
3
3
  head.title: 'server/'
4
4
  description: The server/ directory is used to register API and server handlers to your application.
5
- navigation.icon: i-lucide-folder
5
+ navigation.icon: i-vscode-icons-folder-type-server
6
6
  ---
7
7
 
8
8
  Nuxt automatically scans files inside these directories to register API and server handlers with Hot Module Replacement (HMR) support.
@@ -24,7 +24,7 @@ The handler can directly return JSON data, a `Promise`, or use `event.node.res.e
24
24
  ```ts twoslash [server/api/hello.ts]
25
25
  export default defineEventHandler((event) => {
26
26
  return {
27
- hello: 'world'
27
+ hello: 'world',
28
28
  }
29
29
  })
30
30
  ```
@@ -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/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/guide/directory-structure/app/pages#dynamic-routes) do.
62
62
  ::
63
63
 
64
64
  ## Server Middleware
@@ -115,9 +115,9 @@ For example, you can define a custom handler utility that wraps the original han
115
115
  import type { EventHandler, EventHandlerRequest } from 'h3'
116
116
 
117
117
  export const defineWrappedResponseHandler = <T extends EventHandlerRequest, D> (
118
- handler: EventHandler<T, D>
118
+ handler: EventHandler<T, D>,
119
119
  ): EventHandler<T, D> =>
120
- defineEventHandler<T>(async event => {
120
+ defineEventHandler<T>(async (event) => {
121
121
  try {
122
122
  // do something before the route handler
123
123
  const response = await handler(event)
@@ -234,10 +234,10 @@ You can now universally call this API using:
234
234
 
235
235
  ```vue [app/app.vue]
236
236
  <script setup lang="ts">
237
- async function submit() {
237
+ async function submit () {
238
238
  const { body } = await $fetch('/api/submit', {
239
239
  method: 'post',
240
- body: { test: 123 }
240
+ body: { test: 123 },
241
241
  })
242
242
  }
243
243
  </script>
@@ -269,11 +269,11 @@ If no errors are thrown, a status code of `200 OK` will be returned.
269
269
 
270
270
  Any uncaught errors will return a `500 Internal Server Error` HTTP Error.
271
271
 
272
- To return other error codes, throw an exception with [`createError`](/docs/api/utils/create-error):
272
+ To return other error codes, throw an exception with [`createError`](/docs/4.x/api/utils/create-error):
273
273
 
274
274
  ```ts [server/api/validation/[id\\].ts]
275
275
  export default defineEventHandler((event) => {
276
- const id = parseInt(event.context.params.id) as number
276
+ const id = Number.parseInt(event.context.params.id) as number
277
277
 
278
278
  if (!Number.isInteger(id)) {
279
279
  throw createError({
@@ -287,7 +287,7 @@ export default defineEventHandler((event) => {
287
287
 
288
288
  ### Status Codes
289
289
 
290
- To return other status codes, use the [`setResponseStatus`](/docs/api/utils/set-response-status) utility.
290
+ To return other status codes, use the [`setResponseStatus`](/docs/4.x/api/utils/set-response-status) utility.
291
291
 
292
292
  For example, to return `202 Accepted`
293
293
 
@@ -306,8 +306,8 @@ export default defineEventHandler(async (event) => {
306
306
 
307
307
  const repo = await $fetch('https://api.github.com/repos/nuxt/nuxt', {
308
308
  headers: {
309
- Authorization: `token ${config.githubToken}`
310
- }
309
+ Authorization: `token ${config.githubToken}`,
310
+ },
311
311
  })
312
312
 
313
313
  return repo
@@ -316,8 +316,8 @@ export default defineEventHandler(async (event) => {
316
316
  ```ts [nuxt.config.ts]
317
317
  export default defineNuxtConfig({
318
318
  runtimeConfig: {
319
- githubToken: ''
320
- }
319
+ githubToken: '',
320
+ },
321
321
  })
322
322
  ```
323
323
  ```ini [.env]
@@ -326,7 +326,7 @@ NUXT_GITHUB_TOKEN='<my-super-token>'
326
326
  ::
327
327
 
328
328
  ::note
329
- 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.
329
+ 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.
330
330
  ::
331
331
 
332
332
  ### Request Cookies
@@ -363,8 +363,8 @@ The `event.waitUntil` method accepts a promise that will be awaited before the h
363
363
 
364
364
  ```ts [server/api/background-task.ts]
365
365
  const timeConsumingBackgroundTask = async () => {
366
- await new Promise((resolve) => setTimeout(resolve, 1000))
367
- };
366
+ await new Promise(resolve => setTimeout(resolve, 1000))
367
+ }
368
368
 
369
369
  export default eventHandler((event) => {
370
370
  // schedule a background task without blocking the response
@@ -372,7 +372,7 @@ export default eventHandler((event) => {
372
372
 
373
373
  // immediately send the response to the client
374
374
  return 'done'
375
- });
375
+ })
376
376
  ```
377
377
 
378
378
  ## Advanced Usage
@@ -388,11 +388,11 @@ This is an advanced option. Custom config can affect production deployments, as
388
388
  ```ts [nuxt.config.ts]
389
389
  export default defineNuxtConfig({
390
390
  // https://nitro.build/config
391
- nitro: {}
391
+ nitro: {},
392
392
  })
393
393
  ```
394
394
 
395
- :read-more{to="/docs/guide/concepts/server-engine"}
395
+ :read-more{to="/docs/4.x/guide/concepts/server-engine"}
396
396
 
397
397
  ### Nested Router
398
398
 
@@ -454,7 +454,7 @@ Never combine `next()` callback with a legacy middleware that is `async` or retu
454
454
 
455
455
  ### Server Storage
456
456
 
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](#server-plugins).
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).
458
458
 
459
459
  **Example of adding a Redis storage:**
460
460
 
@@ -468,14 +468,14 @@ export default defineNuxtConfig({
468
468
  driver: 'redis',
469
469
  /* redis connector options */
470
470
  port: 6379, // Redis port
471
- host: "127.0.0.1", // Redis host
472
- username: "", // needs Redis >= 6
473
- password: "",
471
+ host: '127.0.0.1', // Redis host
472
+ username: '', // needs Redis >= 6
473
+ password: '',
474
474
  db: 0, // Defaults to 0
475
- tls: {} // tls/ssl
476
- }
477
- }
478
- }
475
+ tls: {}, // tls/ssl
476
+ },
477
+ },
478
+ },
479
479
  })
480
480
  ```
481
481
 
@@ -511,11 +511,11 @@ export default defineNitroPlugin(() => {
511
511
 
512
512
  // Dynamically pass in credentials from runtime configuration, or other sources
513
513
  const driver = redisDriver({
514
- base: 'redis',
515
- host: useRuntimeConfig().redis.host,
516
- port: useRuntimeConfig().redis.port,
517
- /* other redis connector options */
518
- })
514
+ base: 'redis',
515
+ host: useRuntimeConfig().redis.host,
516
+ port: useRuntimeConfig().redis.port,
517
+ /* other redis connector options */
518
+ })
519
519
 
520
520
  // Mount driver
521
521
  storage.mount('redis', driver)
@@ -529,8 +529,8 @@ export default defineNuxtConfig({
529
529
  host: '',
530
530
  port: 0,
531
531
  /* other redis connector options */
532
- }
533
- }
532
+ },
533
+ },
534
534
  })
535
535
  ```
536
536
  ::
@@ -2,7 +2,7 @@
2
2
  title: 'shared'
3
3
  head.title: 'shared/'
4
4
  description: 'Use the shared/ directory to share functionality between the Vue app and the Nitro server.'
5
- navigation.icon: i-lucide-folder
5
+ navigation.icon: i-vscode-icons-folder-type-shared
6
6
  ---
7
7
 
8
8
  The `shared/` directory allows you to share code that can be used in both the Vue app and the Nitro server.
@@ -35,7 +35,7 @@ export default function (input: string) {
35
35
  }
36
36
  ```
37
37
 
38
- You can now use [auto-imported](/docs/guide/directory-structure/shared#auto-imports) utilities in your Nuxt app and `server/` directory.
38
+ You can now use [auto-imported](/docs/4.x/guide/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">
@@ -52,7 +52,7 @@ const hello = capitalize('hello')
52
52
  ```ts [server/api/hello.get.ts]
53
53
  export default defineEventHandler((event) => {
54
54
  return {
55
- hello: capitalize('hello')
55
+ hello: capitalize('hello'),
56
56
  }
57
57
  })
58
58
  ```
@@ -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/guide/directory-structure/app/composables) and [`app/utils/`](/docs/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/guide/directory-structure/app/composables) and [`app/utils/`](/docs/4.x/guide/directory-structure/app/utils) directories.
66
66
  ::
67
67
 
68
- :read-more{to="/docs/guide/directory-structure/app/composables#how-files-are-scanned"}
68
+ :read-more{to="/docs/4.x/guide/directory-structure/app/composables#how-files-are-scanned"}
69
69
 
70
70
  ```bash [Directory Structure]
71
71
  -| shared/
@@ -77,7 +77,7 @@ The way `shared/utils` and `shared/types` auto-imports work and are scanned is i
77
77
  -----| formatters
78
78
  -------| upper.ts # Not auto-imported
79
79
  ---| types/
80
- -----| bar.d.ts # Auto-imported
80
+ -----| bar.ts # Auto-imported
81
81
  ```
82
82
 
83
83
  Any other files you create in the `shared/` folder must be manually imported using the `#shared` alias (automatically configured by Nuxt):
@@ -95,4 +95,4 @@ import upper from '#shared/utils/formatters/upper'
95
95
 
96
96
  This alias ensures consistent imports across your application, regardless of the importing file's location.
97
97
 
98
- :read-more{to="/docs/guide/concepts/auto-imports"}
98
+ :read-more{to="/docs/4.x/guide/concepts/auto-imports"}
@@ -2,16 +2,16 @@
2
2
  title: ".env"
3
3
  description: "A .env file specifies your build/dev-time environment variables."
4
4
  head.title: ".env"
5
- navigation.icon: i-lucide-file
5
+ 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/guide/directory-structure/gitignore) file to avoid pushing secrets to your repository.
9
+ This file should be added to your [`.gitignore`](/docs/4.x/guide/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/api/commands/build) and [`nuxt generate`](/docs/api/commands/generate).
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).
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/guide/going-further/runtime-config) instead of plain env variables.
37
+ In your application code, you should use [Runtime Config](/docs/4.x/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/guide/going-further/runtime-config#environment-variables).
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).
60
60
  ::
61
61
 
62
62
  ## Production Preview
63
63
 
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.
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.
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 @@ DATABASE_HOST=mydatabaseconnectionstring node .output/server/index.mjs
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/guide/going-further/runtime-config"}
74
+ :read-more{to="/docs/4.x/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/guide/directory-structure/app-config"}
78
+ :read-more{to="/docs/4.x/guide/directory-structure/app-config"}
79
79
  ::
@@ -2,7 +2,7 @@
2
2
  title: ".gitignore"
3
3
  description: "A .gitignore file specifies intentionally untracked files that git should ignore."
4
4
  head.title: ".gitignore"
5
- navigation.icon: i-lucide-file
5
+ navigation.icon: i-vscode-icons-file-type-git
6
6
  ---
7
7
 
8
8
  A `.gitignore` file specifies intentionally untracked files that git should ignore.
@@ -2,15 +2,16 @@
2
2
  title: .nuxtignore
3
3
  head.title: '.nuxtignore'
4
4
  description: The .nuxtignore file lets Nuxt ignore files in your project’s root directory during the build phase.
5
- navigation.icon: i-lucide-file
5
+ navigation.icon: i-vscode-icons-file-type-nuxt
6
+
6
7
  ---
7
8
 
8
- The `.nuxtignore` file tells Nuxt to ignore files in your project’s root directory ([`rootDir`](/docs/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/4.x/api/nuxt-config#rootdir)) during the build phase.
9
10
 
10
- It is subject to the same specification as [`.gitignore`](/docs/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/guide/directory-structure/gitignore) and `.eslintignore` files, in which each line is a glob pattern indicating which files should be ignored.
11
12
 
12
13
  ::tip
13
- 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.
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
15
  ::
15
16
 
16
17
  ## Usage
@@ -2,13 +2,13 @@
2
2
  title: ".nuxtrc"
3
3
  description: "The .nuxtrc file allows you to define nuxt configurations in a flat syntax."
4
4
  head.title: ".nuxtrc"
5
- navigation.icon: i-lucide-file
5
+ navigation.icon: i-vscode-icons-file-type-nuxt
6
6
  ---
7
7
 
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/guide/directory-structure/nuxt-config).
11
+ For more advanced configurations, use [`nuxt.config`](/docs/4.x/guide/directory-structure/nuxt-config).
12
12
  ::
13
13
 
14
14
  ## Usage
@@ -28,10 +28,10 @@ modules[]=nuxt-security
28
28
  If present, the properties in the `nuxt.config` file will overwrite the properties in `.nuxtrc` file.
29
29
 
30
30
  ::note
31
- 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.
31
+ 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.
32
32
  ::
33
33
 
34
- ::read-more{to="/docs/api/configuration/nuxt-config"}
34
+ ::read-more{to="/docs/4.x/api/configuration/nuxt-config"}
35
35
  Discover all the available options in the **Nuxt configuration** documentation.
36
36
  ::
37
37
 
@@ -2,7 +2,7 @@
2
2
  title: "nuxt.config.ts"
3
3
  description: "Nuxt can be easily configured with a single nuxt.config file."
4
4
  head.title: "nuxt.config.ts"
5
- navigation.icon: i-lucide-file
5
+ navigation.icon: i-vscode-icons-file-type-nuxt
6
6
  ---
7
7
 
8
8
  The `nuxt.config` file extension can either be `.js`, `.ts` or `.mjs`.
@@ -27,8 +27,8 @@ export default defineNuxtConfig({
27
27
  })
28
28
  ```
29
29
 
30
- ::read-more{to="/docs/api/configuration/nuxt-config"}
30
+ ::read-more{to="/docs/4.x/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/guide/directory-structure/env), [`.nuxtignore`](/docs/guide/directory-structure/nuxtignore) and [`.nuxtrc`](/docs/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/guide/directory-structure/env), [`.nuxtignore`](/docs/4.x/guide/directory-structure/nuxtignore) and [`.nuxtrc`](/docs/4.x/guide/directory-structure/nuxtrc) dotfiles.
@@ -2,7 +2,7 @@
2
2
  title: package.json
3
3
  head.title: package.json
4
4
  description: The package.json file contains all the dependencies and scripts for your application.
5
- navigation.icon: i-lucide-file
5
+ navigation.icon: i-vscode-icons-file-type-npm
6
6
  ---
7
7
 
8
8
  The minimal `package.json` of your Nuxt application should looks like:
@@ -2,10 +2,10 @@
2
2
  title: "tsconfig.json"
3
3
  description: "Nuxt generates multiple TypeScript configuration files with sensible defaults and your aliases."
4
4
  head.title: "tsconfig.json"
5
- navigation.icon: i-lucide-file
5
+ navigation.icon: i-vscode-icons-file-type-tsconfig
6
6
  ---
7
7
 
8
- Nuxt [automatically generates](/docs/guide/concepts/typescript) multiple TypeScript configuration files (`.nuxt/tsconfig.app.json`, `.nuxt/tsconfig.server.json`, `.nuxt/tsconfig.node.json` and `.nuxt/tsconfig.shared.json`) with the resolved aliases you are using in your Nuxt project, as well as with other sensible defaults.
8
+ Nuxt [automatically generates](/docs/4.x/guide/concepts/typescript) multiple TypeScript configuration files (`.nuxt/tsconfig.app.json`, `.nuxt/tsconfig.server.json`, `.nuxt/tsconfig.node.json` and `.nuxt/tsconfig.shared.json`) with the resolved aliases you are using in your Nuxt project, as well as with other sensible defaults.
9
9
 
10
10
  You can benefit from this by creating a `tsconfig.json` in the root of your project with the following content:
11
11
 
@@ -34,5 +34,5 @@ As you need to, you can customize the contents of this file. However, it is reco
34
34
  ::
35
35
 
36
36
  ::note
37
- If you need to customize your `paths`, this will override the auto-generated path aliases. Instead, we recommend that you add any path aliases you need to the [`alias`](/docs/api/nuxt-config#alias) property within your `nuxt.config`, where they will get picked up and added to the auto-generated `tsconfig`.
37
+ If you need to customize your `paths`, this will override the auto-generated path aliases. Instead, we recommend that you add any path aliases you need to the [`alias`](/docs/4.x/api/nuxt-config#alias) property within your `nuxt.config`, where they will get picked up and added to the auto-generated `tsconfig`.
38
38
  ::