@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
@@ -19,7 +19,7 @@ If you want to play around with Nuxt in your browser, you can [try it out in one
19
19
 
20
20
  Nuxt uses conventions and an opinionated directory structure to automate repetitive tasks and allow developers to focus on pushing features. The configuration file can still customize and override its default behaviors.
21
21
 
22
- - **File-based routing:** define routes based on the structure of your [`pages/` directory](/docs/guide/directory-structure/pages). This can make it easier to organize your application and avoid the need for manual route configuration.
22
+ - **File-based routing:** define routes based on the structure of your [`app/pages/` directory](/docs/guide/directory-structure/app/pages). This can make it easier to organize your application and avoid the need for manual route configuration.
23
23
  - **Code splitting:** Nuxt automatically splits your code into smaller chunks, which can help reduce the initial load time of your application.
24
24
  - **Server-side rendering out of the box:** Nuxt comes with built-in SSR capabilities, so you don't have to set up a separate server yourself.
25
25
  - **Auto-imports:** write Vue composables and components in their respective directories and use them without having to import them with the benefits of tree-shaking and optimized JS bundles.
@@ -90,7 +90,7 @@ NUXT_API_SECRET=api_secret_token
90
90
 
91
91
  These variables are exposed to the rest of your application using the [`useRuntimeConfig()`](/docs/api/composables/use-runtime-config) composable.
92
92
 
93
- ```vue [pages/index.vue]
93
+ ```vue [app/pages/index.vue]
94
94
  <script setup lang="ts">
95
95
  const runtimeConfig = useRuntimeConfig()
96
96
  </script>
@@ -118,7 +118,7 @@ export default defineAppConfig({
118
118
 
119
119
  These variables are exposed to the rest of your application using the [`useAppConfig`](/docs/api/composables/use-app-config) composable.
120
120
 
121
- ```vue [pages/index.vue]
121
+ ```vue [app/pages/index.vue]
122
122
  <script setup lang="ts">
123
123
  const appConfig = useAppConfig()
124
124
  </script>
@@ -10,7 +10,7 @@ navigation.icon: i-lucide-panels-top-left
10
10
 
11
11
  By default, Nuxt will treat this file as the **entrypoint** and render its content for every route of the application.
12
12
 
13
- ```vue [app.vue]
13
+ ```vue [app/app.vue]
14
14
  <template>
15
15
  <div>
16
16
  <h1>Welcome to the homepage</h1>
@@ -26,11 +26,11 @@ If you are familiar with Vue, you might wonder where `main.js` is (the file that
26
26
 
27
27
  ![Components are reusable pieces of UI](/assets/docs/getting-started/views/components.svg)
28
28
 
29
- Most components are reusable pieces of the user interface, like buttons and menus. In Nuxt, you can create these components in the [`components/`](/docs/guide/directory-structure/components) directory, and they will be automatically available across your application without having to explicitly import them.
29
+ Most components are reusable pieces of the user interface, like buttons and menus. In Nuxt, you can create these components in the [`app/components/`](/docs/guide/directory-structure/app/components) directory, and they will be automatically available across your application without having to explicitly import them.
30
30
 
31
31
  ::code-group
32
32
 
33
- ```vue [app.vue]
33
+ ```vue [app/app.vue]
34
34
  <template>
35
35
  <div>
36
36
  <h1>Welcome to the homepage</h1>
@@ -41,7 +41,7 @@ Most components are reusable pieces of the user interface, like buttons and menu
41
41
  </template>
42
42
  ```
43
43
 
44
- ```vue [components/AppAlert.vue]
44
+ ```vue [app/components/AppAlert.vue]
45
45
  <template>
46
46
  <span>
47
47
  <slot />
@@ -55,13 +55,13 @@ Most components are reusable pieces of the user interface, like buttons and menu
55
55
 
56
56
  ![Pages are views tied to a specific route](/assets/docs/getting-started/views/pages.svg)
57
57
 
58
- Pages represent views for each specific route pattern. Every file in the [`pages/`](/docs/guide/directory-structure/pages) directory represents a different route displaying its content.
58
+ Pages represent views for each specific route pattern. Every file in the [`app/pages/`](/docs/guide/directory-structure/app/pages) directory represents a different route displaying its content.
59
59
 
60
- To use pages, create `pages/index.vue` file and add `<NuxtPage />` component to the [`app.vue`](/docs/guide/directory-structure/app) (or remove `app.vue` for default entry). You can now create more pages and their corresponding routes by adding new files in the [`pages/`](/docs/guide/directory-structure/pages) directory.
60
+ To use pages, create an `app/pages/index.vue` file and add `<NuxtPage />` component to the [`app/app.vue`](/docs/guide/directory-structure/app) (or remove `app/app.vue` for default entry). You can now create more pages and their corresponding routes by adding new files in the [`app/pages/`](/docs/guide/directory-structure/app/pages) directory.
61
61
 
62
62
  ::code-group
63
63
 
64
- ```vue [pages/index.vue]
64
+ ```vue [app/pages/index.vue]
65
65
  <template>
66
66
  <div>
67
67
  <h1>Welcome to the homepage</h1>
@@ -72,7 +72,7 @@ To use pages, create `pages/index.vue` file and add `<NuxtPage />` component to
72
72
  </template>
73
73
  ```
74
74
 
75
- ```vue [pages/about.vue]
75
+ ```vue [app/pages/about.vue]
76
76
  <template>
77
77
  <section>
78
78
  <p>This page will be displayed at the /about route.</p>
@@ -88,15 +88,15 @@ To use pages, create `pages/index.vue` file and add `<NuxtPage />` component to
88
88
 
89
89
  ![Layouts are wrapper around pages](/assets/docs/getting-started/views/layouts.svg)
90
90
 
91
- Layouts are wrappers around pages that contain a common User Interface for several pages, such as header and footer displays. Layouts are Vue files using `<slot />` components to display the **page** content. The `layouts/default.vue` file will be used by default. Custom layouts can be set as part of your page metadata.
91
+ Layouts are wrappers around pages that contain a common User Interface for several pages, such as header and footer displays. Layouts are Vue files using `<slot />` components to display the **page** content. The `app/layouts/default.vue` file will be used by default. Custom layouts can be set as part of your page metadata.
92
92
 
93
93
  ::note
94
- If you only have a single layout in your application, we recommend using [`app.vue`](/docs/guide/directory-structure/app) with [`<NuxtPage />`](/docs/api/components/nuxt-page) instead.
94
+ If you only have a single layout in your application, we recommend using [`app/app.vue`](/docs/guide/directory-structure/app) with [`<NuxtPage />`](/docs/api/components/nuxt-page) instead.
95
95
  ::
96
96
 
97
97
  ::code-group
98
98
 
99
- ```vue [app.vue]
99
+ ```vue [app/app.vue]
100
100
  <template>
101
101
  <div>
102
102
  <NuxtLayout>
@@ -106,7 +106,7 @@ If you only have a single layout in your application, we recommend using [`app.v
106
106
  </template>
107
107
  ```
108
108
 
109
- ```vue [layouts/default.vue]
109
+ ```vue [app/layouts/default.vue]
110
110
  <template>
111
111
  <div>
112
112
  <AppHeader />
@@ -116,7 +116,7 @@ If you only have a single layout in your application, we recommend using [`app.v
116
116
  </template>
117
117
  ```
118
118
 
119
- ```vue [pages/index.vue]
119
+ ```vue [app/pages/index.vue]
120
120
  <template>
121
121
  <div>
122
122
  <h1>Welcome to the homepage</h1>
@@ -127,7 +127,7 @@ If you only have a single layout in your application, we recommend using [`app.v
127
127
  </template>
128
128
  ```
129
129
 
130
- ```vue [pages/about.vue]
130
+ ```vue [app/pages/about.vue]
131
131
  <template>
132
132
  <section>
133
133
  <p>This page will be displayed at the /about route.</p>
@@ -137,7 +137,7 @@ If you only have a single layout in your application, we recommend using [`app.v
137
137
 
138
138
  ::
139
139
 
140
- If you want to create more layouts and learn how to use them in your pages, find more information in the [Layouts section](/docs/guide/directory-structure/layouts).
140
+ If you want to create more layouts and learn how to use them in your pages, find more information in the [Layouts section](/docs/guide/directory-structure/app/layouts).
141
141
 
142
142
  ## Advanced: Extending the HTML Template
143
143
 
@@ -7,7 +7,7 @@ navigation.icon: i-lucide-image
7
7
  Nuxt uses two directories to handle assets like stylesheets, fonts or images.
8
8
 
9
9
  - The [`public/`](/docs/guide/directory-structure/public) directory content is served at the server root as-is.
10
- - The [`assets/`](/docs/guide/directory-structure/assets) directory contains by convention every asset that you want the build tool (Vite or webpack) to process.
10
+ - The [`app/assets/`](/docs/guide/directory-structure/app/assets) directory contains by convention every asset that you want the build tool (Vite or webpack) to process.
11
11
 
12
12
  ## Public Directory
13
13
 
@@ -19,7 +19,7 @@ You can get a file in the [`public/`](/docs/guide/directory-structure/public) di
19
19
 
20
20
  For example, referencing an image file in the `public/img/` directory, available at the static URL `/img/nuxt.png`:
21
21
 
22
- ```vue [app.vue]
22
+ ```vue [app/app.vue]
23
23
  <template>
24
24
  <img src="/img/nuxt.png" alt="Discover Nuxt" />
25
25
  </template>
@@ -29,20 +29,20 @@ For example, referencing an image file in the `public/img/` directory, available
29
29
 
30
30
  Nuxt uses [Vite](https://vite.dev/guide/assets.html) (default) or [webpack](https://webpack.js.org/guides/asset-management) to build and bundle your application. The main function of these build tools is to process JavaScript files, but they can be extended through [plugins](https://vite.dev/plugins) (for Vite) or [loaders](https://webpack.js.org/loaders) (for webpack) to process other kinds of assets, like stylesheets, fonts or SVGs. This step transforms the original file, mainly for performance or caching purposes (such as stylesheet minification or browser cache invalidation).
31
31
 
32
- By convention, Nuxt uses the [`assets/`](/docs/guide/directory-structure/assets) directory to store these files but there is no auto-scan functionality for this directory, and you can use any other name for it.
32
+ By convention, Nuxt uses the [`app/assets/`](/docs/guide/directory-structure/app/assets) directory to store these files but there is no auto-scan functionality for this directory, and you can use any other name for it.
33
33
 
34
- In your application's code, you can reference a file located in the [`assets/`](/docs/guide/directory-structure/assets) directory by using the `~/assets/` path.
34
+ In your application's code, you can reference a file located in the [`app/assets/`](/docs/guide/directory-structure/app/assets) directory by using the `~/assets/` path.
35
35
 
36
36
  ### Example
37
37
 
38
38
  For example, referencing an image file that will be processed if a build tool is configured to handle this file extension:
39
39
 
40
- ```vue [app.vue]
40
+ ```vue [app/app.vue]
41
41
  <template>
42
42
  <img src="~/assets/img/nuxt.png" alt="Discover Nuxt" />
43
43
  </template>
44
44
  ```
45
45
 
46
46
  ::note
47
- Nuxt won't serve files in the [`assets/`](/docs/guide/directory-structure/assets) directory at a static URL like `/assets/my-file.png`. If you need a static URL, use the [`public/`](#public-directory) directory.
47
+ Nuxt won't serve files in the [`app/assets/`](/docs/guide/directory-structure/app/assets) directory at a static URL like `/assets/my-file.png`. If you need a static URL, use the [`public/`](#public-directory) directory.
48
48
  ::
@@ -9,14 +9,14 @@ You can use CSS preprocessors, CSS frameworks, UI libraries and Nuxt modules to
9
9
 
10
10
  ## Local Stylesheets
11
11
 
12
- If you're writing local stylesheets, the natural place to put them is the [`assets/` directory](/docs/guide/directory-structure/assets).
12
+ If you're writing local stylesheets, the natural place to put them is the [`app/assets/` directory](/docs/guide/directory-structure/app/assets).
13
13
 
14
14
  ### Importing Within Components
15
15
 
16
16
  You can import stylesheets in your pages, layouts and components directly.
17
17
  You can use a JavaScript import, or a CSS [`@import` statement](https://developer.mozilla.org/en-US/docs/Web/CSS/@import).
18
18
 
19
- ```vue [pages/index.vue]
19
+ ```vue [app/pages/index.vue]
20
20
  <script>
21
21
  // Use a static import for server-side compatibility
22
22
  import '~/assets/css/first.css'
@@ -37,7 +37,7 @@ The stylesheets will be inlined in the HTML rendered by Nuxt.
37
37
  ### The CSS Property
38
38
 
39
39
  You can also use the `css` property in the Nuxt configuration.
40
- The natural place for your stylesheets is the [`assets/` directory](/docs/guide/directory-structure/assets). You can then reference its path and Nuxt will include it to all the pages of your application.
40
+ The natural place for your stylesheets is the [`app/assets/` directory](/docs/guide/directory-structure/app/assets). You can then reference its path and Nuxt will include it to all the pages of your application.
41
41
 
42
42
  ```ts [nuxt.config.ts]
43
43
  export default defineNuxtConfig({
@@ -99,7 +99,7 @@ bun install animate.css
99
99
 
100
100
  Then you can reference it directly in your pages, layouts and components:
101
101
 
102
- ```vue [app.vue]
102
+ ```vue [app/app.vue]
103
103
  <script>
104
104
  import 'animate.css'
105
105
  </script>
@@ -185,10 +185,10 @@ npm install -D stylus
185
185
 
186
186
  ::
187
187
 
188
- The natural place to write your stylesheets is the `assets` directory.
188
+ The natural place to write your stylesheets is the `app/assets` directory.
189
189
  You can then import your source files in your `app.vue` (or layouts files) using your preprocessor's syntax.
190
190
 
191
- ```vue [pages/app.vue]
191
+ ```vue [app/pages/app.vue]
192
192
  <style lang="scss">
193
193
  @use "~/assets/scss/main.scss";
194
194
  </style>
@@ -208,7 +208,7 @@ In both cases, the compiled stylesheets will be inlined in the HTML rendered by
208
208
 
209
209
  If you need to inject code in pre-processed files, like a [Sass partial](https://sass-lang.com/documentation/at-rules/use#partials) with color variables, you can do so with the Vite [preprocessors options](https://vite.dev/config/shared-options.html#css-preprocessoroptions).
210
210
 
211
- Create some partials in your `assets` directory:
211
+ Create some partials in your `app/assets` directory:
212
212
 
213
213
  ::code-group{sync="preprocessor"}
214
214
 
@@ -492,7 +492,7 @@ Use different styles for different layouts.
492
492
  </style>
493
493
  ```
494
494
 
495
- :read-more{to="/docs/guide/directory-structure/layouts"}
495
+ :read-more{to="/docs/guide/directory-structure/app/layouts"}
496
496
 
497
497
  ## Third Party Libraries And Modules
498
498
 
@@ -4,11 +4,11 @@ description: Nuxt file-system routing creates a route for every file in the page
4
4
  navigation.icon: i-lucide-milestone
5
5
  ---
6
6
 
7
- One core feature of Nuxt is the file system router. Every Vue file inside the [`pages/`](/docs/guide/directory-structure/pages) directory creates a corresponding URL (or route) that displays the contents of the file. By using dynamic imports for each page, Nuxt leverages code-splitting to ship the minimum amount of JavaScript for the requested route.
7
+ One core feature of Nuxt is the file system router. Every Vue file inside the [`app/pages/`](/docs/guide/directory-structure/app/pages) directory creates a corresponding URL (or route) that displays the contents of the file. By using dynamic imports for each page, Nuxt leverages code-splitting to ship the minimum amount of JavaScript for the requested route.
8
8
 
9
9
  ## Pages
10
10
 
11
- Nuxt routing is based on [vue-router](https://router.vuejs.org) and generates the routes from every component created in the [`pages/` directory](/docs/guide/directory-structure/pages), based on their filename.
11
+ Nuxt routing is based on [vue-router](https://router.vuejs.org) and generates the routes from every component created in the [`app/pages/` directory](/docs/guide/directory-structure/app/pages), based on their filename.
12
12
 
13
13
  This file system routing uses naming conventions to create dynamic and nested routes:
14
14
 
@@ -43,7 +43,7 @@ This file system routing uses naming conventions to create dynamic and nested ro
43
43
 
44
44
  ::
45
45
 
46
- :read-more{to="/docs/guide/directory-structure/pages"}
46
+ :read-more{to="/docs/guide/directory-structure/app/pages"}
47
47
 
48
48
  ## Navigation
49
49
 
@@ -51,7 +51,7 @@ The [`<NuxtLink>`](/docs/api/components/nuxt-link) component links pages between
51
51
 
52
52
  When a [`<NuxtLink>`](/docs/api/components/nuxt-link) enters the viewport on the client side, Nuxt will automatically prefetch components and payload (generated pages) of the linked pages ahead of time, resulting in faster navigation.
53
53
 
54
- ```vue [pages/index.vue]
54
+ ```vue [app/pages/index.vue]
55
55
  <template>
56
56
  <header>
57
57
  <nav>
@@ -93,8 +93,8 @@ Route middleware runs within the Vue part of your Nuxt app. Despite the similar
93
93
  There are three kinds of route middleware:
94
94
 
95
95
  1. Anonymous (or inline) route middleware, which are defined directly in the pages where they are used.
96
- 2. Named route middleware, which are placed in the [`middleware/`](/docs/guide/directory-structure/middleware) directory and will be automatically loaded via asynchronous import when used on a page. (**Note**: The route middleware name is normalized to kebab-case, so `someMiddleware` becomes `some-middleware`.)
97
- 3. Global route middleware, which are placed in the [`middleware/`](/docs/guide/directory-structure/middleware) directory (with a `.global` suffix) and will be automatically run on every route change.
96
+ 2. Named route middleware, which are placed in the [`app/middleware/`](/docs/guide/directory-structure/app/middleware) directory and will be automatically loaded via asynchronous import when used on a page. (**Note**: The route middleware name is normalized to kebab-case, so `someMiddleware` becomes `some-middleware`.)
97
+ 3. Global route middleware, which are placed in the [`app/middleware/`](/docs/guide/directory-structure/app/middleware) directory (with a `.global` suffix) and will be automatically run on every route change.
98
98
 
99
99
  Example of an `auth` middleware protecting the `/dashboard` page:
100
100
 
@@ -125,7 +125,7 @@ definePageMeta({
125
125
 
126
126
  ::
127
127
 
128
- :read-more{to="/docs/guide/directory-structure/middleware"}
128
+ :read-more{to="/docs/guide/directory-structure/app/middleware"}
129
129
 
130
130
  ## Route Validation
131
131
 
@@ -60,7 +60,7 @@ export default defineNuxtConfig({
60
60
 
61
61
  The [`useHead`](/docs/api/composables/use-head) composable function supports reactive input, allowing you to manage your head tags programmatically.
62
62
 
63
- ```vue twoslash [app.vue]
63
+ ```vue twoslash [app/app.vue]
64
64
  <script setup lang="ts">
65
65
  useHead({
66
66
  title: 'My App',
@@ -83,7 +83,7 @@ The [`useSeoMeta`](/docs/api/composables/use-seo-meta) composable lets you defin
83
83
 
84
84
  This helps you avoid typos and common mistakes, such as using `name` instead of `property`.
85
85
 
86
- ```vue twoslash [app.vue]
86
+ ```vue twoslash [app/app.vue]
87
87
  <script setup lang="ts">
88
88
  useSeoMeta({
89
89
  title: 'My Amazing Site',
@@ -109,7 +109,7 @@ the capitalization of these components ensuring we don't use invalid native HTML
109
109
 
110
110
  <!-- @case-police-ignore html -->
111
111
 
112
- ```vue [app.vue]
112
+ ```vue [app/app.vue]
113
113
  <script setup lang="ts">
114
114
  const title = ref('Hello World')
115
115
  </script>
@@ -183,7 +183,7 @@ Reactivity is supported on all properties, by providing a computed value, a gett
183
183
  </script>
184
184
  ```
185
185
 
186
- ```vue [Components]
186
+ ```vue [app/Components]
187
187
  <script setup lang="ts">
188
188
  const description = ref('My amazing site.')
189
189
  </script>
@@ -267,7 +267,7 @@ useHead({
267
267
 
268
268
  ### With `definePageMeta`
269
269
 
270
- Within your [`pages/` directory](/docs/guide/directory-structure/pages), you can use `definePageMeta` along with [`useHead`](/docs/api/composables/use-head) to set metadata based on the current route.
270
+ Within your [`app/pages/` directory](/docs/guide/directory-structure/app/pages), you can use `definePageMeta` along with [`useHead`](/docs/api/composables/use-head) to set metadata based on the current route.
271
271
 
272
272
  For example, you can first set the current page title (this is extracted at build time via a macro, so it can't be set dynamically):
273
273
 
@@ -293,13 +293,13 @@ useHead({
293
293
 
294
294
  :link-example{to="/docs/examples/features/meta-tags"}
295
295
 
296
- :read-more{to="/docs/guide/directory-structure/pages/#page-metadata"}
296
+ :read-more{to="/docs/guide/directory-structure/app/pages/#page-metadata"}
297
297
 
298
298
  ### Dynamic Title
299
299
 
300
300
  In the example below, `titleTemplate` is set either as a string with the `%s` placeholder or as a `function`, which allows greater flexibility in setting the page title dynamically for each route of your Nuxt app:
301
301
 
302
- ```vue twoslash [app.vue]
302
+ ```vue twoslash [app/app.vue]
303
303
  <script setup lang="ts">
304
304
  useHead({
305
305
  // as a string,
@@ -309,7 +309,7 @@ useHead({
309
309
  </script>
310
310
  ```
311
311
 
312
- ```vue twoslash [app.vue]
312
+ ```vue twoslash [app/app.vue]
313
313
  <script setup lang="ts">
314
314
  useHead({
315
315
  // or as a function
@@ -348,7 +348,7 @@ The example below shows how you might enable Google Fonts using either the `link
348
348
  </script>
349
349
  ```
350
350
 
351
- ```vue [Components]
351
+ ```vue [app/Components]
352
352
  <template>
353
353
  <div>
354
354
  <Link rel="preconnect" href="https://fonts.googleapis.com" />
@@ -10,7 +10,7 @@ Nuxt leverages Vue's [`<Transition>`](https://vuejs.org/guide/built-ins/transiti
10
10
 
11
11
  ## Page Transitions
12
12
 
13
- You can enable page transitions to apply an automatic transition for all your [pages](/docs/guide/directory-structure/pages).
13
+ You can enable page transitions to apply an automatic transition for all your [pages](/docs/guide/directory-structure/app/pages).
14
14
 
15
15
  ```ts twoslash [nuxt.config.ts]
16
16
  export default defineNuxtConfig({
@@ -28,7 +28,7 @@ To start adding transition between your pages, add the following CSS to your [`a
28
28
 
29
29
  ::code-group
30
30
 
31
- ```vue [app.vue]
31
+ ```vue [app/app.vue]
32
32
  <template>
33
33
  <NuxtPage />
34
34
  </template>
@@ -46,7 +46,7 @@ To start adding transition between your pages, add the following CSS to your [`a
46
46
  </style>
47
47
  ```
48
48
 
49
- ```vue [pages/index.vue]
49
+ ```vue [app/pages/index.vue]
50
50
  <template>
51
51
  <div>
52
52
  <h1>Home page</h1>
@@ -55,7 +55,7 @@ To start adding transition between your pages, add the following CSS to your [`a
55
55
  </template>
56
56
  ```
57
57
 
58
- ```vue [pages/about.vue]
58
+ ```vue [app/pages/about.vue]
59
59
  <template>
60
60
  <div>
61
61
  <h1>About page</h1>
@@ -86,7 +86,7 @@ definePageMeta({
86
86
  </script>
87
87
  ```
88
88
 
89
- ```vue [app.vue]
89
+ ```vue [app/app.vue]
90
90
  <template>
91
91
  <NuxtPage />
92
92
  </template>
@@ -115,7 +115,7 @@ Moving to the about page will add the 3d rotation effect:
115
115
 
116
116
  ## Layout Transitions
117
117
 
118
- You can enable layout transitions to apply an automatic transition for all your [layouts](/docs/guide/directory-structure/layouts).
118
+ You can enable layout transitions to apply an automatic transition for all your [layouts](/docs/guide/directory-structure/app/layouts).
119
119
 
120
120
  ```ts twoslash [nuxt.config.ts]
121
121
  export default defineNuxtConfig({
@@ -129,7 +129,7 @@ To start adding transition between your pages and layouts, add the following CSS
129
129
 
130
130
  ::code-group
131
131
 
132
- ```vue [app.vue]
132
+ ```vue [app/app.vue]
133
133
  <template>
134
134
  <NuxtLayout>
135
135
  <NuxtPage />
@@ -148,7 +148,7 @@ To start adding transition between your pages and layouts, add the following CSS
148
148
  </style>
149
149
  ```
150
150
 
151
- ```vue [layouts/default.vue]
151
+ ```vue [app/layouts/default.vue]
152
152
  <template>
153
153
  <div>
154
154
  <pre>default layout</pre>
@@ -163,7 +163,7 @@ div {
163
163
  </style>
164
164
  ```
165
165
 
166
- ```vue [layouts/orange.vue]
166
+ ```vue [app/layouts/orange.vue]
167
167
  <template>
168
168
  <div>
169
169
  <pre>orange layout</pre>
@@ -180,7 +180,7 @@ div {
180
180
  </style>
181
181
  ```
182
182
 
183
- ```vue [pages/index.vue]
183
+ ```vue [app/pages/index.vue]
184
184
  <template>
185
185
  <div>
186
186
  <h1>Home page</h1>
@@ -189,7 +189,7 @@ div {
189
189
  </template>
190
190
  ```
191
191
 
192
- ```vue [pages/about.vue]
192
+ ```vue [app/pages/about.vue]
193
193
  <script setup lang="ts">
194
194
  definePageMeta({
195
195
  layout: 'orange'
@@ -315,7 +315,7 @@ Learn more about additional [JavaScript hooks](https://vuejs.org/guide/built-ins
315
315
 
316
316
  ## Dynamic Transitions
317
317
 
318
- To apply dynamic transitions using conditional logic, you can leverage inline [middleware](/docs/guide/directory-structure/middleware) to assign a different transition name to `to.meta.pageTransition`.
318
+ To apply dynamic transitions using conditional logic, you can leverage inline [middleware](/docs/guide/directory-structure/app/middleware) to assign a different transition name to `to.meta.pageTransition`.
319
319
 
320
320
  ::code-group
321
321
 
@@ -363,7 +363,7 @@ definePageMeta({
363
363
  </style>
364
364
  ```
365
365
 
366
- ```vue [layouts/default.vue]
366
+ ```vue [app/layouts/default.vue]
367
367
  <script setup lang="ts">
368
368
  const route = useRoute()
369
369
  const id = computed(() => Number(route.params.id || 1))
@@ -394,7 +394,7 @@ The page now applies the `slide-left` transition when going to the next id and `
394
394
 
395
395
  When `<NuxtPage />` is used in `app.vue`, transitions can be configured with the `transition` prop to activate transitions globally.
396
396
 
397
- ```vue [app.vue]
397
+ ```vue [app/app.vue]
398
398
  <template>
399
399
  <div>
400
400
  <NuxtLayout>
@@ -431,7 +431,7 @@ The possible values are: `false`, `true`, or `'always'`.
431
431
 
432
432
  If set to true, Nuxt will not apply transitions if the user's browser matches `prefers-reduced-motion: reduce` (recommended). If set to `always`, Nuxt will always apply the transition and it is up to you to respect the user's preference.
433
433
 
434
- By default, view transitions are enabled for all [pages](/docs/guide/directory-structure/pages), but you can set a different global default.
434
+ By default, view transitions are enabled for all [pages](/docs/guide/directory-structure/app/pages), but you can set a different global default.
435
435
 
436
436
  ```ts twoslash [nuxt.config.ts]
437
437
  export default defineNuxtConfig({
@@ -26,7 +26,7 @@ The payload is a JavaScript object accessible through [`useNuxtApp().payload`](/
26
26
  Use the [Nuxt DevTools](https://devtools.nuxt.com) to inspect this data in the **Payload tab**.
27
27
  ::
28
28
 
29
- ```vue [app.vue]
29
+ ```vue [app/app.vue]
30
30
  <script setup lang="ts">
31
31
  const { data } = await useFetch('/api/data')
32
32
 
@@ -132,7 +132,7 @@ Be very careful before proxying headers to an external API and just include head
132
132
 
133
133
  The [`useFetch`](/docs/api/composables/use-fetch) composable uses `$fetch` under-the-hood to make SSR-safe network calls in the setup function.
134
134
 
135
- ```vue twoslash [app.vue]
135
+ ```vue twoslash [app/app.vue]
136
136
  <script setup lang="ts">
137
137
  const { data: count } = await useFetch('/api/count')
138
138
  </script>
@@ -163,7 +163,7 @@ It's developer experience sugar for the most common use case. (You can find out
163
163
 
164
164
  There are some cases when using the [`useFetch`](/docs/api/composables/use-fetch) composable is not appropriate, for example when a CMS or a third-party provide their own query layer. In this case, you can use [`useAsyncData`](/docs/api/composables/use-async-data) to wrap your calls and still keep the benefits provided by the composable.
165
165
 
166
- ```vue [pages/users.vue]
166
+ ```vue [app/pages/users.vue]
167
167
  <script setup lang="ts">
168
168
  const { data, error } = await useAsyncData('users', () => myGetFunction('users'))
169
169
 
@@ -180,7 +180,7 @@ Since the autogenerated key only takes into account the file and line where `use
180
180
  Setting a key can be useful to share the same data between components using [`useNuxtData`](/docs/api/composables/use-nuxt-data) or to [refresh specific data](/docs/api/utils/refresh-nuxt-data#refresh-specific-data).
181
181
  ::
182
182
 
183
- ```vue [pages/users/[id\\].vue]
183
+ ```vue [app/pages/users/[id\\].vue]
184
184
  <script setup lang="ts">
185
185
  const { id } = useRoute().params
186
186
 
@@ -252,7 +252,7 @@ If you have not fetched data on the server (for example, with `server: false`),
252
252
 
253
253
  By default, data fetching composables will wait for the resolution of their asynchronous function before navigating to a new page by using Vue's Suspense. This feature can be ignored on client-side navigation with the `lazy` option. In that case, you will have to manually handle loading state using the `status` value.
254
254
 
255
- ```vue twoslash [app.vue]
255
+ ```vue twoslash [app/app.vue]
256
256
  <script setup lang="ts">
257
257
  const { status, data: posts } = useFetch('/api/posts', {
258
258
  lazy: true
@@ -581,7 +581,7 @@ However, when calling `useFetch` with a relative URL on the server, Nuxt will us
581
581
 
582
582
  If you want to pass on/proxy cookies in the other direction, from an internal request back to the client, you will need to handle this yourself.
583
583
 
584
- ```ts [composables/fetch.ts]
584
+ ```ts [app/composables/fetch.ts]
585
585
  import { appendResponseHeader } from 'h3'
586
586
  import type { H3Event } from 'h3'
587
587
 
@@ -660,7 +660,7 @@ export default defineEventHandler(() => {
660
660
  })
661
661
  ```
662
662
 
663
- ```vue [app.vue]
663
+ ```vue [app/app.vue]
664
664
  <script setup lang="ts">
665
665
  // Type of `data` is inferred as string even though we returned a Date object
666
666
  const { data } = await useFetch('/api/foo')
@@ -691,7 +691,7 @@ export default defineEventHandler(() => {
691
691
 
692
692
  ```
693
693
 
694
- ```vue [app.vue]
694
+ ```vue [app/app.vue]
695
695
  <script setup lang="ts">
696
696
  // Type of `data` is inferred as
697
697
  // {
@@ -729,7 +729,7 @@ export default defineEventHandler(() => {
729
729
  })
730
730
  ```
731
731
 
732
- ```vue [app.vue]
732
+ ```vue [app/app.vue]
733
733
  <script setup lang="ts">
734
734
  import superjson from 'superjson'
735
735
 
@@ -35,7 +35,7 @@ Instead use `const useX = () => useState('x')`
35
35
 
36
36
  In this example, we use a component-local counter state. Any other component that uses `useState('counter')` shares the same reactive state.
37
37
 
38
- ```vue twoslash [app.vue]
38
+ ```vue twoslash [app/app.vue]
39
39
  <script setup lang="ts">
40
40
  const counter = useState('counter', () => Math.round(Math.random() * 1000))
41
41
  </script>
@@ -63,7 +63,7 @@ To globally invalidate cached state, see [`clearNuxtState`](/docs/api/utils/clea
63
63
 
64
64
  Most of the time, you will want to initialize your state with data that resolves asynchronously. You can use the [`app.vue`](/docs/guide/directory-structure/app) component with the [`callOnce`](/docs/api/utils/call-once) util to do so.
65
65
 
66
- ```vue twoslash [app.vue]
66
+ ```vue twoslash [app/app.vue]
67
67
  <script setup lang="ts">
68
68
  const websiteConfig = useState('config')
69
69
 
@@ -104,7 +104,7 @@ export const useWebsiteStore = defineStore('websiteStore', {
104
104
  }
105
105
  })
106
106
  ```
107
- ```vue [app.vue]
107
+ ```vue [app/app.vue]
108
108
  <script setup lang="ts">
109
109
  const website = useWebsiteStore()
110
110
 
@@ -123,7 +123,7 @@ await callOnce(website.fetch)
123
123
  ## Advanced Usage
124
124
 
125
125
  ::code-group
126
- ```ts [composables/locale.ts]
126
+ ```ts [app/composables/locale.ts]
127
127
  import type { Ref } from 'vue'
128
128
 
129
129
  export const useLocale = () => {
@@ -165,7 +165,7 @@ export const useLocaleDate = (date: Ref<Date> | Date, locale = useLocale()) => {
165
165
  }
166
166
  ```
167
167
 
168
- ```vue [app.vue]
168
+ ```vue [app/app.vue]
169
169
  <script setup lang="ts">
170
170
  const locales = useLocales()
171
171
  const locale = useLocale()
@@ -191,13 +191,13 @@ const date = useLocaleDate(new Date('2016-10-26'))
191
191
 
192
192
  ## Shared State
193
193
 
194
- By using [auto-imported composables](/docs/guide/directory-structure/composables) we can define global type-safe states and import them across the app.
194
+ By using [auto-imported composables](/docs/guide/directory-structure/app/composables) we can define global type-safe states and import them across the app.
195
195
 
196
196
  ```ts twoslash [composables/states.ts]
197
197
  export const useColor = () => useState<string>('color', () => 'pink')
198
198
  ```
199
199
 
200
- ```vue [app.vue]
200
+ ```vue [app/app.vue]
201
201
  <script setup lang="ts">
202
202
  // ---cut-start---
203
203
  const useColor = () => useState<string>('color', () => 'pink')
@@ -215,7 +215,7 @@ The `#error` slot will receive `error` as a prop. (If you set `error = null` it
215
215
  If you navigate to another route, the error will be cleared automatically.
216
216
  ::
217
217
 
218
- ```vue [pages/index.vue]
218
+ ```vue [app/pages/index.vue]
219
219
  <template>
220
220
  <!-- some content -->
221
221
  <NuxtErrorBoundary @error="someErrorLogger">