@nuxt/docs-nightly 4.1.1-29282072.39113ab4 → 4.1.1-29283054.32d56553

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 (99) hide show
  1. package/1.getting-started/01.introduction.md +1 -1
  2. package/1.getting-started/03.configuration.md +2 -2
  3. package/1.getting-started/04.views.md +15 -15
  4. package/1.getting-started/05.assets.md +6 -6
  5. package/1.getting-started/06.styling.md +8 -8
  6. package/1.getting-started/07.routing.md +7 -7
  7. package/1.getting-started/08.seo-meta.md +9 -9
  8. package/1.getting-started/09.transitions.md +15 -15
  9. package/1.getting-started/10.data-fetching.md +9 -9
  10. package/1.getting-started/11.state-management.md +7 -7
  11. package/1.getting-started/12.error-handling.md +1 -1
  12. package/1.getting-started/14.layers.md +2 -2
  13. package/1.getting-started/15.prerendering.md +2 -2
  14. package/1.getting-started/17.testing.md +1 -1
  15. package/1.getting-started/18.upgrade.md +7 -7
  16. package/2.guide/1.concepts/1.auto-imports.md +6 -6
  17. package/2.guide/1.concepts/10.nuxt-lifecycle.md +6 -6
  18. package/2.guide/1.concepts/2.vuejs-development.md +3 -3
  19. package/2.guide/1.concepts/3.rendering.md +2 -2
  20. package/2.guide/1.concepts/8.typescript.md +1 -1
  21. package/2.guide/2.directory-structure/1.app/1.components.md +18 -18
  22. package/2.guide/2.directory-structure/1.app/1.composables.md +11 -11
  23. package/2.guide/2.directory-structure/1.app/1.layouts.md +7 -7
  24. package/2.guide/2.directory-structure/1.app/1.middleware.md +3 -3
  25. package/2.guide/2.directory-structure/1.app/1.pages.md +15 -15
  26. package/2.guide/2.directory-structure/1.app/1.plugins.md +7 -7
  27. package/2.guide/2.directory-structure/1.app/1.utils.md +3 -3
  28. package/2.guide/2.directory-structure/1.app/3.app-config.md +2 -2
  29. package/2.guide/2.directory-structure/1.app/3.app.md +12 -12
  30. package/2.guide/2.directory-structure/1.content.md +2 -2
  31. package/2.guide/2.directory-structure/1.public.md +1 -1
  32. package/2.guide/2.directory-structure/1.server.md +3 -3
  33. package/2.guide/2.directory-structure/1.shared.md +3 -3
  34. package/2.guide/3.going-further/1.experimental-features.md +5 -5
  35. package/2.guide/3.going-further/10.runtime-config.md +2 -2
  36. package/2.guide/3.going-further/2.hooks.md +1 -1
  37. package/2.guide/3.going-further/6.nuxt-app.md +2 -2
  38. package/2.guide/3.going-further/7.layers.md +7 -7
  39. package/2.guide/4.recipes/1.custom-routing.md +1 -1
  40. package/2.guide/4.recipes/2.vite-plugin.md +1 -1
  41. package/2.guide/4.recipes/3.custom-usefetch.md +4 -4
  42. package/2.guide/4.recipes/4.sessions-and-authentication.md +4 -4
  43. package/2.guide/5.best-practices/performance.md +2 -2
  44. package/3.api/1.components/1.client-only.md +2 -2
  45. package/3.api/1.components/1.dev-only.md +1 -1
  46. package/3.api/1.components/1.nuxt-client-fallback.md +1 -1
  47. package/3.api/1.components/12.nuxt-route-announcer.md +2 -2
  48. package/3.api/1.components/2.nuxt-page.md +8 -8
  49. package/3.api/1.components/3.nuxt-layout.md +13 -13
  50. package/3.api/1.components/4.nuxt-link.md +9 -9
  51. package/3.api/1.components/5.nuxt-loading-indicator.md +2 -2
  52. package/3.api/1.components/7.nuxt-welcome.md +1 -1
  53. package/3.api/2.composables/on-prehydrate.md +1 -1
  54. package/3.api/2.composables/use-async-data.md +3 -3
  55. package/3.api/2.composables/use-cookie.md +1 -1
  56. package/3.api/2.composables/use-fetch.md +2 -2
  57. package/3.api/2.composables/use-lazy-async-data.md +1 -1
  58. package/3.api/2.composables/use-lazy-fetch.md +1 -1
  59. package/3.api/2.composables/use-nuxt-app.md +7 -7
  60. package/3.api/2.composables/use-nuxt-data.md +4 -4
  61. package/3.api/2.composables/use-preview-mode.md +1 -1
  62. package/3.api/2.composables/use-request-fetch.md +1 -1
  63. package/3.api/2.composables/use-request-header.md +1 -1
  64. package/3.api/2.composables/use-request-headers.md +1 -1
  65. package/3.api/2.composables/use-request-url.md +1 -1
  66. package/3.api/2.composables/use-response-header.md +3 -3
  67. package/3.api/2.composables/use-route-announcer.md +1 -1
  68. package/3.api/2.composables/use-router.md +5 -5
  69. package/3.api/2.composables/use-runtime-config.md +1 -1
  70. package/3.api/2.composables/use-seo-meta.md +3 -3
  71. package/3.api/2.composables/use-server-seo-meta.md +1 -1
  72. package/3.api/3.utils/$fetch.md +4 -4
  73. package/3.api/3.utils/abort-navigation.md +4 -4
  74. package/3.api/3.utils/add-route-middleware.md +5 -5
  75. package/3.api/3.utils/call-once.md +2 -2
  76. package/3.api/3.utils/create-error.md +1 -1
  77. package/3.api/3.utils/define-nuxt-component.md +2 -2
  78. package/3.api/3.utils/define-nuxt-route-middleware.md +3 -3
  79. package/3.api/3.utils/define-page-meta.md +12 -12
  80. package/3.api/3.utils/define-route-rules.md +1 -1
  81. package/3.api/3.utils/navigate-to.md +1 -1
  82. package/3.api/3.utils/on-nuxt-ready.md +1 -1
  83. package/3.api/3.utils/refresh-cookie.md +1 -1
  84. package/3.api/3.utils/refresh-nuxt-data.md +2 -2
  85. package/3.api/3.utils/set-page-layout.md +1 -1
  86. package/3.api/4.commands/add.md +7 -7
  87. package/3.api/5.kit/7.pages.md +1 -1
  88. package/3.api/5.kit/8.layout.md +1 -1
  89. package/3.api/5.kit/9.plugins.md +1 -1
  90. package/3.api/6.nuxt-config.md +12 -17
  91. package/6.bridge/4.plugins-and-middleware.md +3 -3
  92. package/6.bridge/6.meta.md +1 -1
  93. package/7.migration/2.configuration.md +2 -2
  94. package/7.migration/3.auto-imports.md +1 -1
  95. package/7.migration/5.plugins-and-middleware.md +2 -2
  96. package/7.migration/6.pages-and-layouts.md +8 -8
  97. package/7.migration/7.component-options.md +4 -4
  98. package/7.migration/8.runtime-config.md +1 -1
  99. package/package.json +1 -1
@@ -17,7 +17,7 @@ Nuxt will automatically create a route for every page in your `~/pages/` directo
17
17
 
18
18
  ::code-group
19
19
 
20
- ```vue [pages/index.vue]
20
+ ```vue [app/pages/index.vue]
21
21
  <template>
22
22
  <h1>Index page</h1>
23
23
  </template>
@@ -44,11 +44,11 @@ export default defineComponent({
44
44
 
45
45
  ::
46
46
 
47
- The `pages/index.vue` file will be mapped to the `/` route of your application.
47
+ The `app/pages/index.vue` file will be mapped to the `/` route of your application.
48
48
 
49
49
  If you are using [`app.vue`](/docs/guide/directory-structure/app), make sure to use the [`<NuxtPage/>`](/docs/api/components/nuxt-page) component to display the current page:
50
50
 
51
- ```vue [app.vue]
51
+ ```vue [app/app.vue]
52
52
  <template>
53
53
  <div>
54
54
  <!-- Markup shared across all pages, ex: NavBar -->
@@ -65,7 +65,7 @@ Here are some examples to illustrate what a page with a single root element look
65
65
 
66
66
  ::code-group
67
67
 
68
- ```vue [pages/working.vue]
68
+ ```vue [app/pages/working.vue]
69
69
  <template>
70
70
  <div>
71
71
  <!-- This page correctly has only one single root element -->
@@ -74,14 +74,14 @@ Here are some examples to illustrate what a page with a single root element look
74
74
  </template>
75
75
  ```
76
76
 
77
- ```vue [pages/bad-1.vue]
77
+ ```vue [app/pages/bad-1.vue]
78
78
  <template>
79
79
  <!-- This page will not render when route changes during client side navigation, because of this comment -->
80
80
  <div>Page content</div>
81
81
  </template>
82
82
  ```
83
83
 
84
- ```vue [pages/bad-2.vue]
84
+ ```vue [app/pages/bad-2.vue]
85
85
  <template>
86
86
  <div>This page</div>
87
87
  <div>Has more than one root element</div>
@@ -106,7 +106,7 @@ If you want a parameter to be _optional_, you must enclose it in double square b
106
106
 
107
107
  Given the example above, you can access group/id within your component via the `$route` object:
108
108
 
109
- ```vue [pages/users-[group\\]/[id\\].vue]
109
+ ```vue [app/pages/users-[group\\]/[id\\].vue]
110
110
  <template>
111
111
  <p>{{ $route.params.group }} - {{ $route.params.id }}</p>
112
112
  </template>
@@ -140,7 +140,7 @@ Named parent routes will take priority over nested dynamic routes. For the `/foo
140
140
 
141
141
  If you need a catch-all route, you create it by using a file named like `[...slug].vue`. This will match _all_ routes under that path.
142
142
 
143
- ```vue [pages/[...slug\\].vue]
143
+ ```vue [app/pages/[...slug\\].vue]
144
144
  <template>
145
145
  <p>{{ $route.params.slug }}</p>
146
146
  </template>
@@ -184,7 +184,7 @@ This file tree will generate these routes:
184
184
  ]
185
185
  ```
186
186
 
187
- To display the `child.vue` component, you have to insert the `<NuxtPage>` component inside `pages/parent.vue`:
187
+ To display the `child.vue` component, you have to insert the `<NuxtPage>` component inside `app/pages/parent.vue`:
188
188
 
189
189
  ```vue {}[pages/parent.vue]
190
190
  <template>
@@ -315,7 +315,7 @@ You can set a default value for this property [in your `nuxt.config`](/docs/api/
315
315
 
316
316
  #### `layout`
317
317
 
318
- You can define the layout used to render the route. This can be either false (to disable any layout), a string or a ref/computed, if you want to make it reactive in some way. [More about layouts](/docs/guide/directory-structure/layouts).
318
+ You can define the layout used to render the route. This can be either false (to disable any layout), a string or a ref/computed, if you want to make it reactive in some way. [More about layouts](/docs/guide/directory-structure/app/layouts).
319
319
 
320
320
  #### `layoutTransition` and `pageTransition`
321
321
 
@@ -325,7 +325,7 @@ You can set default values for these properties [in your `nuxt.config`](/docs/ap
325
325
 
326
326
  #### `middleware`
327
327
 
328
- You can define middleware to apply before loading this page. It will be merged with all the other middleware used in any matching parent/child routes. It can be a string, a function (an anonymous/inlined middleware function following [the global before guard pattern](https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards)), or an array of strings/functions. [More about named middleware](/docs/guide/directory-structure/middleware).
328
+ You can define middleware to apply before loading this page. It will be merged with all the other middleware used in any matching parent/child routes. It can be a string, a function (an anonymous/inlined middleware function following [the global before guard pattern](https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards)), or an array of strings/functions. [More about named middleware](/docs/guide/directory-structure/app/middleware).
329
329
 
330
330
  #### `name`
331
331
 
@@ -360,7 +360,7 @@ To navigate between pages of your app, you should use the [`<NuxtLink>`](/docs/a
360
360
 
361
361
  This component is included with Nuxt and therefore you don't have to import it as you do with other components.
362
362
 
363
- A simple link to the `index.vue` page in your `pages` folder:
363
+ A simple link to the `index.vue` page in your `app/pages` folder:
364
364
 
365
365
  ```vue
366
366
  <template>
@@ -399,11 +399,11 @@ function navigate(){
399
399
 
400
400
  ## Client-Only Pages
401
401
 
402
- You can define a page as [client only](/docs/guide/directory-structure/components#client-components) by giving it a `.client.vue` suffix. None of the content of this page will be rendered on the server.
402
+ You can define a page as [client only](/docs/guide/directory-structure/app/components#client-components) by giving it a `.client.vue` suffix. None of the content of this page will be rendered on the server.
403
403
 
404
404
  ## Server-Only Pages
405
405
 
406
- You can define a page as [server only](/docs/guide/directory-structure/components#server-components) by giving it a `.server.vue` suffix. While you will be able to navigate to the page using client-side navigation, controlled by `vue-router`, it will be rendered with a server component automatically, meaning the code required to render the page will not be in your client-side bundle.
406
+ You can define a page as [server only](/docs/guide/directory-structure/app/components#server-components) by giving it a `.server.vue` suffix. While you will be able to navigate to the page using client-side navigation, controlled by `vue-router`, it will be rendered with a server component automatically, meaning the code required to render the page will not be in your client-side bundle.
407
407
 
408
408
  ::warning
409
409
  Server-only pages must have a single root element. (HTML comments are considered elements as well.)
@@ -417,7 +417,7 @@ As your app gets bigger and more complex, your routing might require more flexib
417
417
 
418
418
  ## Multiple Pages Directories
419
419
 
420
- By default, all your pages should be in one `pages` directory at the root of your project.
420
+ By default, all your pages should be in one `app/pages` directory at the root of your project.
421
421
 
422
422
  However, you can use [Nuxt Layers](/docs/getting-started/layers) to create groupings of your app's pages:
423
423
 
@@ -5,7 +5,7 @@ head.title: "plugins/"
5
5
  navigation.icon: i-lucide-folder
6
6
  ---
7
7
 
8
- Nuxt automatically reads the files in the `plugins/` directory and loads them at the creation of the Vue application.
8
+ Nuxt automatically reads the files in the `app/plugins/` directory and loads them at the creation of the Vue application.
9
9
 
10
10
  ::note
11
11
  All plugins inside are auto-registered, you don't need to add them to your `nuxt.config` separately.
@@ -30,7 +30,7 @@ Only files at the top level of the directory (or index files within any subdirec
30
30
 
31
31
  Only `foo.ts` and `bar/index.ts` would be registered.
32
32
 
33
- To add plugins in subdirectories, you can use the [`plugins`](/docs/api/nuxt-config#plugins-1) option in `nuxt.config.ts`:
33
+ To add plugins in subdirectories, you can use the [`app/plugins`](/docs/api/nuxt-config#plugins-1) option in `nuxt.config.ts`:
34
34
 
35
35
  ```ts twoslash [nuxt.config.ts]
36
36
  export default defineNuxtConfig({
@@ -134,9 +134,9 @@ export default defineNuxtPlugin({
134
134
 
135
135
  ## Using Composables
136
136
 
137
- You can use [composables](/docs/guide/directory-structure/composables) as well as [utils](/docs/guide/directory-structure/utils) within Nuxt plugins:
137
+ You can use [composables](/docs/guide/directory-structure/app/composables) as well as [utils](/docs/guide/directory-structure/app/utils) within Nuxt plugins:
138
138
 
139
- ```ts [plugins/hello.ts]
139
+ ```ts [app/plugins/hello.ts]
140
140
  export default defineNuxtPlugin((nuxtApp) => {
141
141
  const foo = useFoo()
142
142
  })
@@ -186,7 +186,7 @@ export default defineNuxtPlugin({
186
186
 
187
187
  You can then use the helper in your components:
188
188
 
189
- ```vue [components/Hello.vue]
189
+ ```vue [app/components/Hello.vue]
190
190
  <script setup lang="ts">
191
191
  // alternatively, you can also use it here
192
192
  const { $hello } = useNuxtApp()
@@ -200,7 +200,7 @@ const { $hello } = useNuxtApp()
200
200
  ```
201
201
 
202
202
  ::important
203
- Note that we highly recommend using [`composables`](/docs/guide/directory-structure/composables) instead of providing helpers to avoid polluting the global namespace and keep your main bundle entry small.
203
+ Note that we highly recommend using [`composables`](/docs/guide/directory-structure/app/composables) instead of providing helpers to avoid polluting the global namespace and keep your main bundle entry small.
204
204
  ::
205
205
 
206
206
  ::warning
@@ -261,7 +261,7 @@ bun add -D vue-gtag-next
261
261
 
262
262
  Then create a plugin file:
263
263
 
264
- ```ts [plugins/vue-gtag.client.ts]
264
+ ```ts [app/plugins/vue-gtag.client.ts]
265
265
  import VueGtag, { trackRouter } from 'vue-gtag-next'
266
266
 
267
267
  export default defineNuxtPlugin((nuxtApp) => {
@@ -5,7 +5,7 @@ description: Use the utils/ directory to auto-import your utility functions thro
5
5
  navigation.icon: i-lucide-folder
6
6
  ---
7
7
 
8
- The main purpose of the [`utils/` directory](/docs/guide/directory-structure/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/guide/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
 
@@ -29,7 +29,7 @@ export default function (arr: Array<any>) {
29
29
 
30
30
  You can now use auto imported utility functions in `.js`, `.ts` and `.vue` files
31
31
 
32
- ```vue [app.vue]
32
+ ```vue [app/app.vue]
33
33
  <template>
34
34
  <p>{{ formatNumber(1234) }}</p>
35
35
  </template>
@@ -40,7 +40,7 @@ You can now use auto imported utility functions in `.js`, `.ts` and `.vue` files
40
40
  :link-example{to="/docs/examples/features/auto-imports"}
41
41
 
42
42
  ::tip
43
- The way `utils/` auto-imports work and are scanned is identical to the [`composables/`](/docs/guide/directory-structure/composables) directory.
43
+ The way `app/utils/` auto-imports work and are scanned is identical to the [`app/composables/`](/docs/guide/directory-structure/app/composables) directory.
44
44
  ::
45
45
 
46
46
  ::important
@@ -37,7 +37,7 @@ export default defineAppConfig({
37
37
 
38
38
  We can now universally access `theme` both when server-rendering the page and in the browser using [`useAppConfig`](/docs/api/composables/use-app-config) composable.
39
39
 
40
- ```vue [pages/index.vue]
40
+ ```vue [app/pages/index.vue]
41
41
  <script setup lang="ts">
42
42
  const appConfig = useAppConfig()
43
43
 
@@ -47,7 +47,7 @@ console.log(appConfig.theme)
47
47
 
48
48
  The [`updateAppConfig`](/docs/api/utils/update-app-config) utility can be used to update the `app.config` at runtime.
49
49
 
50
- ```vue [pages/index.vue]
50
+ ```vue [app/pages/index.vue]
51
51
  <script setup>
52
52
  const appConfig = useAppConfig() // { foo: 'bar' }
53
53
 
@@ -6,16 +6,16 @@ navigation.icon: i-lucide-file
6
6
  ---
7
7
 
8
8
  ::tip
9
- If you have a `pages/` directory, the `app.vue` file is optional. Nuxt will automatically include a default `app.vue`, but you can still add your own to customize the structure and content as needed.
9
+ If you have a `app/pages/` directory, the `app.vue` file is optional. Nuxt will automatically include a default `app.vue`, but you can still add your own to customize the structure and content as needed.
10
10
  ::
11
11
 
12
12
  ## Usage
13
13
 
14
14
  ### Minimal Usage
15
15
 
16
- With Nuxt, the [`pages/`](/docs/guide/directory-structure/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/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.
17
17
 
18
- ```vue [app.vue]
18
+ ```vue [app/app.vue]
19
19
  <template>
20
20
  <h1>Hello World!</h1>
21
21
  </template>
@@ -25,9 +25,9 @@ With Nuxt, the [`pages/`](/docs/guide/directory-structure/pages) directory is op
25
25
 
26
26
  ### Usage with Pages
27
27
 
28
- When you have a [`pages/`](/docs/guide/directory-structure/pages) directory, you need to use the [`<NuxtPage>`](/docs/api/components/nuxt-page) component to display the current page:
28
+ When you have a [`app/pages/`](/docs/guide/directory-structure/app/pages) directory, you need to use the [`<NuxtPage>`](/docs/api/components/nuxt-page) component to display the current page:
29
29
 
30
- ```vue [app.vue]
30
+ ```vue [app/app.vue]
31
31
  <template>
32
32
  <NuxtPage />
33
33
  </template>
@@ -35,7 +35,7 @@ When you have a [`pages/`](/docs/guide/directory-structure/pages) directory, you
35
35
 
36
36
  You can also define the common structure of your application directly in `app.vue`. This is useful when you want to include global elements such as a header or footer:
37
37
 
38
- ```vue [app.vue]
38
+ ```vue [app/app.vue]
39
39
  <template>
40
40
  <header>
41
41
  Header content
@@ -51,15 +51,15 @@ 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/guide/directory-structure/pages"}
55
- Learn more about how to structure your pages using the `pages/` directory.
54
+ ::read-more{to="/docs/guide/directory-structure/app/pages"}
55
+ Learn more about how to structure your pages using the `app/pages/` directory.
56
56
  ::
57
57
 
58
58
  ### Usage with Layouts
59
59
 
60
- When your application requires different layouts for different pages, you can use the `layouts/` directory with the [`<NuxtLayout>`](/docs/api/components/nuxt-layout) component. This allows you to define multiple layouts and apply them per page.
60
+ When your application requires different layouts for different pages, you can use the `app/layouts/` directory with the [`<NuxtLayout>`](/docs/api/components/nuxt-layout) component. This allows you to define multiple layouts and apply them per page.
61
61
 
62
- ```vue [app.vue]
62
+ ```vue [app/app.vue]
63
63
  <template>
64
64
  <NuxtLayout>
65
65
  <NuxtPage />
@@ -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/guide/directory-structure/layouts"}
71
- Learn more about how to structure your layouts using the `layouts/` directory.
70
+ ::read-more{to="/docs/guide/directory-structure/app/layouts"}
71
+ Learn more about how to structure your layouts using the `app/layouts/` directory.
72
72
  ::
@@ -36,9 +36,9 @@ 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/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/guide/directory-structure/app/pages/#catch-all-route) using the [`<ContentRenderer>`](https://content.nuxt.com/docs/components/content-renderer) component:
40
40
 
41
- ```vue [pages/[...slug\\].vue]
41
+ ```vue [app/pages/[...slug\\].vue]
42
42
  <script lang="ts" setup>
43
43
  const route = useRoute()
44
44
  const { data: page } = await useAsyncData(route.path, () => {
@@ -14,7 +14,7 @@ Files contained within the `public/` directory are served at the root and are no
14
14
  ---| robots.txt
15
15
  ```
16
16
 
17
- ```vue [app.vue]
17
+ ```vue [app/app.vue]
18
18
  <script setup lang="ts">
19
19
  useSeoMeta({
20
20
  ogImage: '/og-image.png'
@@ -31,7 +31,7 @@ export default defineEventHandler((event) => {
31
31
 
32
32
  You can now universally call this API in your pages and components:
33
33
 
34
- ```vue [pages/index.vue]
34
+ ```vue [app/pages/index.vue]
35
35
  <script setup lang="ts">
36
36
  const { data } = await useFetch('/api/hello')
37
37
  </script>
@@ -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/pages#dynamic-routes) do.
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.
62
62
  ::
63
63
 
64
64
  ## Server Middleware
@@ -232,7 +232,7 @@ Alternatively, use `readValidatedBody` with a schema validator such as Zod for r
232
232
 
233
233
  You can now universally call this API using:
234
234
 
235
- ```vue [app.vue]
235
+ ```vue [app/app.vue]
236
236
  <script setup lang="ts">
237
237
  async function submit() {
238
238
  const { body } = await $fetch('/api/submit', {
@@ -37,7 +37,7 @@ export default function (input: string) {
37
37
 
38
38
  You can now use [auto-imported](/docs/guide/directory-structure/shared#auto-imports) utilities in your Nuxt app and `server/` directory.
39
39
 
40
- ```vue [app.vue]
40
+ ```vue [app/app.vue]
41
41
  <script setup lang="ts">
42
42
  const hello = capitalize('hello')
43
43
  </script>
@@ -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 [`composables/`](/docs/guide/directory-structure/composables) and [`utils/`](/docs/guide/directory-structure/utils) directories.
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.
66
66
  ::
67
67
 
68
- :read-more{to="/docs/guide/directory-structure/composables#how-files-are-scanned"}
68
+ :read-more{to="/docs/guide/directory-structure/app/composables#how-files-are-scanned"}
69
69
 
70
70
  ```bash [Directory Structure]
71
71
  -| shared/
@@ -61,7 +61,7 @@ This feature will likely be removed in a near future.
61
61
 
62
62
  Emits `app:chunkError` hook when there is an error loading vite/webpack chunks. Default behavior is to perform a reload of the new route on navigation to a new route when a chunk fails to load.
63
63
 
64
- If you set this to `'automatic-immediate'` Nuxt will reload the current route immediately, instead of waiting for a navigation. This is useful for chunk errors that are not triggered by navigation, e.g., when your Nuxt app fails to load a [lazy component](/docs/guide/directory-structure/components#dynamic-imports). A potential downside of this behavior is undesired reloads, e.g., when your app does not need the chunk that caused the error.
64
+ If you set this to `'automatic-immediate'` Nuxt will reload the current route immediately, instead of waiting for a navigation. This is useful for chunk errors that are not triggered by navigation, e.g., when your Nuxt app fails to load a [lazy component](/docs/guide/directory-structure/app/components#dynamic-imports). A potential downside of this behavior is undesired reloads, e.g., when your app does not need the chunk that caused the error.
65
65
 
66
66
  You can disable automatic handling by setting this to `false`, or handle chunk errors manually by setting it to `manual`.
67
67
 
@@ -220,7 +220,7 @@ export default defineNuxtConfig({
220
220
  })
221
221
  ```
222
222
 
223
- :read-more{to="/docs/guide/directory-structure/components#server-components"}
223
+ :read-more{to="/docs/guide/directory-structure/app/components#server-components"}
224
224
 
225
225
  ::read-more{icon="i-simple-icons-github" to="https://github.com/nuxt/nuxt/issues/19772" target="_blank"}
226
226
  You can follow the server components roadmap on GitHub.
@@ -423,7 +423,7 @@ export default defineNuxtConfig({
423
423
  })
424
424
  ```
425
425
 
426
- This allows modules to access additional metadata from the page metadata in the build context. If you are using this within a module, it's recommended also to [augment the `NuxtPage` types with your keys](/docs/guide/directory-structure/pages#typing-custom-metadata).
426
+ This allows modules to access additional metadata from the page metadata in the build context. If you are using this within a module, it's recommended also to [augment the `NuxtPage` types with your keys](/docs/guide/directory-structure/app/pages#typing-custom-metadata).
427
427
 
428
428
  ## normalizeComponentNames
429
429
 
@@ -531,7 +531,7 @@ export default defineNuxtConfig({
531
531
  })
532
532
  ```
533
533
 
534
- ::read-more{icon="i-simple-icons-github" color="gray" to="/docs/guide/directory-structure/components#delayed-or-lazy-hydration"}
534
+ ::read-more{icon="i-simple-icons-github" color="gray" to="/docs/guide/directory-structure/app/components#delayed-or-lazy-hydration"}
535
535
  Read more about lazy hydration.
536
536
  ::
537
537
 
@@ -575,7 +575,7 @@ export default defineNuxtConfig({
575
575
  })
576
576
  ```
577
577
 
578
- ```ts [app.vue]
578
+ ```ts [app/app.vue]
579
579
  function something (_method: () => unknown) {
580
580
  return () => 'decorated'
581
581
  }
@@ -97,7 +97,7 @@ The behavior is different between the client-side and server-side:
97
97
  - On server-side, the entire runtime config is available, but it is read-only to avoid context sharing.
98
98
  ::
99
99
 
100
- ```vue [pages/index.vue]
100
+ ```vue [app/pages/index.vue]
101
101
  <script setup lang="ts">
102
102
  const config = useRuntimeConfig()
103
103
 
@@ -122,7 +122,7 @@ if (import.meta.server) {
122
122
 
123
123
  If you want to use the runtime config within any (custom) plugin, you can use [`useRuntimeConfig()`](/docs/api/composables/use-runtime-config) inside of your `defineNuxtPlugin` function.
124
124
 
125
- ```ts [plugins/config.ts]
125
+ ```ts [app/plugins/config.ts]
126
126
  export default defineNuxtPlugin((nuxtApp) => {
127
127
  const config = useRuntimeConfig()
128
128
 
@@ -41,7 +41,7 @@ Explore all available Nuxt hooks.
41
41
 
42
42
  App hooks can be mainly used by [Nuxt Plugins](/docs/guide/directory-structure/plugins) to hook into rendering lifecycle but could also be used in Vue composables.
43
43
 
44
- ```js [plugins/test.ts]
44
+ ```js [app/plugins/test.ts]
45
45
  export default defineNuxtPlugin((nuxtApp) => {
46
46
  nuxtApp.hook('page:start', () => {
47
47
  /* your code goes here */
@@ -23,7 +23,7 @@ Jump over the `NuxtApp` interface documentation.
23
23
 
24
24
  Many composables and utilities, both built-in and user-made, may require access to the Nuxt instance. This doesn't exist everywhere on your application, because a fresh instance is created on every request.
25
25
 
26
- Currently, the Nuxt context is only accessible in [plugins](/docs/guide/directory-structure/plugins), [Nuxt hooks](/docs/guide/going-further/hooks), [Nuxt middleware](/docs/guide/directory-structure/middleware) (if wrapped in `defineNuxtRouteMiddleware`), and [setup functions](https://vuejs.org/api/composition-api-setup.html) (in pages and components).
26
+ Currently, the Nuxt context is only accessible in [plugins](/docs/guide/directory-structure/plugins), [Nuxt hooks](/docs/guide/going-further/hooks), [Nuxt middleware](/docs/guide/directory-structure/app/middleware) (if wrapped in `defineNuxtRouteMiddleware`), and [setup functions](https://vuejs.org/api/composition-api-setup.html) (in pages and components).
27
27
 
28
28
  If a composable is called without access to the context, you may get an error stating that 'A composable that requires access to the Nuxt instance was called outside of a plugin, Nuxt hook, Nuxt middleware, or Vue setup function.' In that case, you can also explicitly call functions within this context by using [`nuxtApp.runWithContext`](/docs/api/composables/use-nuxt-app#runwithcontext).
29
29
 
@@ -31,7 +31,7 @@ If a composable is called without access to the context, you may get an error st
31
31
 
32
32
  Within composables, plugins and components you can access `nuxtApp` with [`useNuxtApp()`](/docs/api/composables/use-nuxt-app):
33
33
 
34
- ```ts [composables/useMyComposable.ts]
34
+ ```ts [app/composables/useMyComposable.ts]
35
35
  export function useMyComposable () {
36
36
  const nuxtApp = useNuxtApp()
37
37
  // access runtime nuxt app instance
@@ -15,13 +15,13 @@ export default defineNuxtConfig({})
15
15
 
16
16
  Additionally, certain other files in the layer directory will be auto-scanned and used by Nuxt for the project extending this layer.
17
17
 
18
- - [`app/components/*`](/docs/guide/directory-structure/components) - Extend the default components
19
- - [`app/composables/*`](/docs/guide/directory-structure/composables) - Extend the default composables
20
- - [`app/layouts/*`](/docs/guide/directory-structure/layouts) - Extend the default layouts
21
- - [`app/middleware/*`](/docs/guide/directory-structure/middleware) - Extend the default middleware
22
- - [`app/pages/*`](/docs/guide/directory-structure/pages) - Extend the default pages
18
+ - [`app/components/*`](/docs/guide/directory-structure/app/components) - Extend the default components
19
+ - [`app/composables/*`](/docs/guide/directory-structure/app/composables) - Extend the default composables
20
+ - [`app/layouts/*`](/docs/guide/directory-structure/app/layouts) - Extend the default layouts
21
+ - [`app/middleware/*`](/docs/guide/directory-structure/app/middleware) - Extend the default middleware
22
+ - [`app/pages/*`](/docs/guide/directory-structure/app/pages) - Extend the default pages
23
23
  - [`app/plugins/*`](/docs/guide/directory-structure/plugins) - Extend the default plugins
24
- - [`app/utils/*`](/docs/guide/directory-structure/utils) - Extend the default utils
24
+ - [`app/utils/*`](/docs/guide/directory-structure/app/utils) - Extend the default utils
25
25
  - [`app/app.config.ts`](/docs/guide/directory-structure/app-config) - Extend the default app config
26
26
  - [`server/*`](/docs/guide/directory-structure/server) - Extend the default server endpoints & middleware
27
27
  - [`nuxt.config.ts`](/docs/guide/directory-structure/nuxt-config)- Extend the default nuxt config
@@ -38,7 +38,7 @@ Additionally, certain other files in the layer directory will be auto-scanned an
38
38
  })
39
39
  ```
40
40
 
41
- ```vue [app.vue]
41
+ ```vue [app/app.vue]
42
42
  <template>
43
43
  <BaseComponent/>
44
44
  </template>
@@ -5,7 +5,7 @@ description: "In Nuxt, your routing is defined by the structure of your files in
5
5
 
6
6
  ## Adding custom routes
7
7
 
8
- In Nuxt, your routing is defined by the structure of your files inside the [pages directory](/docs/guide/directory-structure/pages). However, since it uses [vue-router](https://router.vuejs.org) under the hood, Nuxt offers you several ways to add custom routes in your project.
8
+ In Nuxt, your routing is defined by the structure of your files inside the [app/pages directory](/docs/guide/directory-structure/app/pages). However, since it uses [vue-router](https://router.vuejs.org) under the hood, Nuxt offers you several ways to add custom routes in your project.
9
9
 
10
10
  ### Router Config
11
11
 
@@ -52,7 +52,7 @@ For example, we can have a `config.yaml` that stores configuration data and impo
52
52
  greeting: "Hello, Nuxt with Vite!"
53
53
  ```
54
54
 
55
- ```vue [components/Hello.vue]
55
+ ```vue [app/components/Hello.vue]
56
56
  <script setup>
57
57
  import config from '~/data/hello.yaml'
58
58
  </script>
@@ -23,7 +23,7 @@ Let's pretend here that:
23
23
  - We are storing the JWT token in a session with [nuxt-auth-utils](https://github.com/atinux/nuxt-auth-utils)
24
24
  - If the API responds with a `401` status code, we redirect the user to the `/login` page
25
25
 
26
- ```ts [plugins/api.ts]
26
+ ```ts [app/plugins/api.ts]
27
27
  export default defineNuxtPlugin((nuxtApp) => {
28
28
  const { session } = useUserSession()
29
29
 
@@ -53,7 +53,7 @@ export default defineNuxtPlugin((nuxtApp) => {
53
53
 
54
54
  With this Nuxt plugin, `$api` is exposed from `useNuxtApp()` to make API calls directly from the Vue components:
55
55
 
56
- ```vue [app.vue]
56
+ ```vue [app/app.vue]
57
57
  <script setup>
58
58
  const { $api } = useNuxtApp()
59
59
  const { data: modules } = await useAsyncData('modules', () => $api('/modules'))
@@ -68,7 +68,7 @@ Wrapping with [`useAsyncData`](/docs/api/composables/use-async-data) **avoid dou
68
68
 
69
69
  Now that `$api` has the logic we want, let's create a `useAPI` composable to replace the usage of `useAsyncData` + `$api`:
70
70
 
71
- ```ts [composables/useAPI.ts]
71
+ ```ts [app/composables/useAPI.ts]
72
72
  import type { UseFetchOptions } from 'nuxt/app'
73
73
 
74
74
  export function useAPI<T>(
@@ -84,7 +84,7 @@ export function useAPI<T>(
84
84
 
85
85
  Let's use the new composable and have a nice and clean component:
86
86
 
87
- ```vue [app.vue]
87
+ ```vue [app/app.vue]
88
88
  <script setup>
89
89
  const { data: modules } = await useAPI('/modules')
90
90
  </script>
@@ -91,7 +91,7 @@ const { loggedIn, session, user, clear, fetch } = useUserSession()
91
91
 
92
92
  Let's create a login page with a form to submit the login data to our `/api/login` route.
93
93
 
94
- ```vue [pages/login.vue]
94
+ ```vue [app/pages/login.vue]
95
95
  <script setup lang="ts">
96
96
  const { loggedIn, user, fetch: refreshSession } = useUserSession()
97
97
  const credentials = reactive({
@@ -143,13 +143,13 @@ export default defineEventHandler(async (event) => {
143
143
 
144
144
  ## Protect App Routes
145
145
 
146
- Our data is safe with the server-side route in place, but without doing anything else, unauthenticated users would probably get some odd data when trying to access the `/users` page. We should create a [client-side middleware](https://nuxt.com/docs/guide/directory-structure/middleware) to protect the route on the client side and redirect users to the login page.
146
+ Our data is safe with the server-side route in place, but without doing anything else, unauthenticated users would probably get some odd data when trying to access the `/users` page. We should create a [client-side middleware](https://nuxt.com/docs/guide/directory-structure/app/middleware) to protect the route on the client side and redirect users to the login page.
147
147
 
148
148
  `nuxt-auth-utils` provides a convenient `useUserSession` composable which we'll use to check if the user is logged in, and redirect them if they are not.
149
149
 
150
150
  We'll create a middleware in the `/middleware` directory. Unlike on the server, client-side middleware is not automatically applied to all endpoints, and we'll need to specify where we want it applied.
151
151
 
152
- ```typescript [middleware/authenticated.ts]
152
+ ```typescript [app/middleware/authenticated.ts]
153
153
  export default defineNuxtRouteMiddleware(() => {
154
154
  const { loggedIn } = useUserSession()
155
155
 
@@ -166,7 +166,7 @@ Now that we have our app middleware to protect our routes, we can use it on our
166
166
 
167
167
  We'll use [`definePageMeta`](/docs/api/utils/define-page-meta) to apply the middleware to the route that we want to protect.
168
168
 
169
- ```vue [pages/index.vue]
169
+ ```vue [app/pages/index.vue]
170
170
  <script setup lang="ts">
171
171
  definePageMeta({
172
172
  middleware: ['authenticated'],
@@ -90,7 +90,7 @@ const show = ref(false)
90
90
 
91
91
  By using the Lazy prefix you can delay loading the component code until the right moment, which can be helpful for optimizing your JavaScript bundle size.
92
92
 
93
- :read-more{title="Lazy loading components" to="/docs/guide/directory-structure/components#dynamic-imports"}
93
+ :read-more{title="Lazy loading components" to="/docs/guide/directory-structure/app/components#dynamic-imports"}
94
94
 
95
95
  ### Lazy Hydration
96
96
 
@@ -106,7 +106,7 @@ It is not always necessary to hydrate (or make interactive) all the components o
106
106
 
107
107
  To optimize your app, you may want to delay the hydration of some components until they're visible, or until the browser is done with more important tasks.
108
108
 
109
- :read-more{title="Lazy hydration" to="/docs/guide/directory-structure/components#delayed-or-lazy-hydration"}
109
+ :read-more{title="Lazy hydration" to="/docs/guide/directory-structure/app/components#delayed-or-lazy-hydration"}
110
110
 
111
111
  ### Fetching data
112
112
 
@@ -35,7 +35,7 @@ The content of the default slot will be tree-shaken out of the server build. (Th
35
35
 
36
36
  - `#fallback`: specify a content to be rendered on the server and displayed until `<ClientOnly>` is mounted in the browser.
37
37
 
38
- ```vue [pages/example.vue]
38
+ ```vue [app/pages/example.vue]
39
39
  <template>
40
40
  <div>
41
41
  <Sidebar />
@@ -58,7 +58,7 @@ The content of the default slot will be tree-shaken out of the server build. (Th
58
58
 
59
59
  Components inside `<ClientOnly>` are rendered only after being mounted. To access the rendered elements in the DOM, you can watch a template ref:
60
60
 
61
- ```vue [pages/example.vue]
61
+ ```vue [app/pages/example.vue]
62
62
  <script setup lang="ts">
63
63
  const nuxtWelcomeRef = useTemplateRef('nuxtWelcomeRef')
64
64
 
@@ -12,7 +12,7 @@ Nuxt provides the `<DevOnly>` component to render a component only during develo
12
12
 
13
13
  The content will not be included in production builds.
14
14
 
15
- ```vue [pages/example.vue]
15
+ ```vue [app/pages/example.vue]
16
16
  <template>
17
17
  <div>
18
18
  <Sidebar />
@@ -18,7 +18,7 @@ Nuxt provides the `<NuxtClientFallback>` component to render its content on the
18
18
  This component is experimental and in order to use it you must enable the `experimental.clientFallback` option in your `nuxt.config`.
19
19
  ::
20
20
 
21
- ```vue [pages/example.vue]
21
+ ```vue [app/pages/example.vue]
22
22
  <template>
23
23
  <div>
24
24
  <Sidebar />