@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
@@ -9,8 +9,8 @@ One of the core features of Nuxt is the layers and extending support. You can ex
9
9
  ## Use Cases
10
10
 
11
11
  - Share reusable configuration presets across projects using `nuxt.config` and `app.config`
12
- - Create a component library using [`components/`](/docs/guide/directory-structure/components) directory
13
- - Create utility and composable library using [`composables/`](/docs/guide/directory-structure/composables) and [`utils/`](/docs/guide/directory-structure/utils) directories
12
+ - Create a component library using [`app/components/`](/docs/guide/directory-structure/app/components) directory
13
+ - Create utility and composable library using [`app/composables/`](/docs/guide/directory-structure/app/composables) and [`app/utils/`](/docs/guide/directory-structure/app/utils) directories
14
14
  - Create Nuxt module presets
15
15
  - Share standard setup across projects
16
16
  - Create Nuxt themes
@@ -109,7 +109,7 @@ As a shorthand, you can also configure this in a page file using [`defineRouteRu
109
109
  This feature is experimental and in order to use it you must enable the `experimental.inlineRouteRules` option in your `nuxt.config`.
110
110
  ::
111
111
 
112
- ```vue [pages/index.vue]
112
+ ```vue [app/pages/index.vue]
113
113
  <script setup>
114
114
  // Or set at the page level
115
115
  defineRouteRules({
@@ -141,7 +141,7 @@ export default defineNuxtConfig({
141
141
 
142
142
  You can use this at runtime within a [Nuxt context](/docs/guide/going-further/nuxt-app#the-nuxt-context) to add more routes for Nitro to prerender.
143
143
 
144
- ```vue [pages/index.vue]
144
+ ```vue [app/pages/index.vue]
145
145
  <script setup>
146
146
  prerenderRoutes(["/some/other/url"]);
147
147
  prerenderRoutes("/api/content/article/my-article");
@@ -516,7 +516,7 @@ If you prefer to use `@vue/test-utils` on its own for unit testing in Nuxt, and
516
516
  },
517
517
  ```
518
518
 
519
- 4. Create a simple `<HelloWorld>` component `components/HelloWorld.vue` with the following content:
519
+ 4. Create a simple `<HelloWorld>` component `app/components/HelloWorld.vue` with the following content:
520
520
 
521
521
  ```vue
522
522
  <template>
@@ -104,7 +104,7 @@ This command will execute all codemods in sequence, with the option to deselect
104
104
 
105
105
  🚦 **Impact Level**: Significant
106
106
 
107
- Nuxt now defaults to a new directory structure, with backwards compatibility (so if Nuxt detects you are using the old structure, such as with a top-level `pages/` directory, this new structure will not apply).
107
+ Nuxt now defaults to a new directory structure, with backwards compatibility (so if Nuxt detects you are using the old structure, such as with a top-level `app/pages/` directory, this new structure will not apply).
108
108
 
109
109
  👉 [See full RFC](https://github.com/nuxt/nuxt/issues/26444)
110
110
 
@@ -168,7 +168,7 @@ With this new structure, the `~` alias now points to the `app/` directory by def
168
168
  #### Migration Steps
169
169
 
170
170
  1. Create a new directory called `app/`.
171
- 1. Move your `assets/`, `components/`, `composables/`, `layouts/`, `middleware/`, `pages/`, `plugins/` and `utils/` folders under it, as well as `app.vue`, `error.vue`, `app.config.ts`. If you have an `app/router-options.ts` or `app/spa-loading-template.html`, these paths remain the same.
171
+ 1. Move your `assets/`, `components/`, `composables/`, `app/layouts/`, `app/middleware/`, `app/pages/`, `app/plugins/` and `utils/` folders under it, as well as `app.vue`, `error.vue`, `app.config.ts`. If you have an `app/router-options.ts` or `app/spa-loading-template.html`, these paths remain the same.
172
172
  1. Make sure your `nuxt.config.ts`, `content/`, `layers/`, `modules/`, `public/` and `server/` folders remain outside the `app/` folder, in the root of your project.
173
173
  1. Remember to update any third-party configuration files to work with the new directory structure, such as your `tailwindcss` or `eslint` configuration (if required - `@nuxtjs/tailwindcss` should automatically configure `tailwindcss` correctly).
174
174
 
@@ -223,7 +223,7 @@ These changes have been made to improve memory usage and increase consistency wi
223
223
 
224
224
  It may be beneficial to extract any calls to `useAsyncData` that share an explicit key (and have custom options) into their own composable:
225
225
 
226
- ```ts [composables/useUserData.ts]
226
+ ```ts [app/composables/useUserData.ts]
227
227
  export function useUserData(userId: string) {
228
228
  return useAsyncData(
229
229
  `user-${userId}`,
@@ -658,7 +658,7 @@ Please report an issue if you are doing this, as we do not plan to keep this as
658
658
 
659
659
  Previously it was possible to pass `dedupe: boolean` to `refresh`. These were aliases of `cancel` (`true`) and `defer` (`false`).
660
660
 
661
- ```ts twoslash [app.vue]
661
+ ```ts twoslash [app/app.vue]
662
662
  // @errors: 2322
663
663
  const { refresh } = await useAsyncData(async () => ({ message: 'Hello, Nuxt!' }))
664
664
 
@@ -889,13 +889,13 @@ The data is still available, but can be accessed with `useNuxtApp().payload`:
889
889
 
890
890
  #### What Changed
891
891
 
892
- Child folders in your `middleware/` folder are also scanned for `index` files and these are now also registered as middleware in your project.
892
+ Child folders in your `app/middleware/` folder are also scanned for `index` files and these are now also registered as middleware in your project.
893
893
 
894
894
  #### Reasons for Change
895
895
 
896
- Nuxt scans a number of folders automatically, including `middleware/` and `plugins/`.
896
+ Nuxt scans a number of folders automatically, including `app/middleware/` and `app/plugins/`.
897
897
 
898
- Child folders in your `plugins/` folder are scanned for `index` files and we wanted to make this behavior consistent between scanned directories.
898
+ Child folders in your `app/plugins/` folder are scanned for `index` files and we wanted to make this behavior consistent between scanned directories.
899
899
 
900
900
  #### Migration Steps
901
901
 
@@ -5,13 +5,13 @@ description: "Nuxt auto-imports components, composables, helper functions and Vu
5
5
 
6
6
  Nuxt auto-imports components, composables and [Vue.js APIs](https://vuejs.org/api) to use across your application without explicitly importing them.
7
7
 
8
- ```vue twoslash [app.vue]
8
+ ```vue twoslash [app/app.vue]
9
9
  <script setup lang="ts">
10
10
  const count = ref(1) // ref is auto-imported
11
11
  </script>
12
12
  ```
13
13
 
14
- Thanks to its opinionated directory structure, Nuxt can auto-import your [`components/`](/docs/guide/directory-structure/components), [`composables/`](/docs/guide/directory-structure/composables) and [`utils/`](/docs/guide/directory-structure/utils).
14
+ Thanks to its opinionated directory structure, Nuxt can auto-import your [`app/components/`](/docs/guide/directory-structure/app/components), [`app/composables/`](/docs/guide/directory-structure/app/composables) and [`app/utils/`](/docs/guide/directory-structure/app/utils).
15
15
 
16
16
  Contrary to a classic global declaration, Nuxt preserves typings, IDEs completions and hints, and **only includes what is used in your production code**.
17
17
 
@@ -101,9 +101,9 @@ export const useMyComposable = () => {
101
101
 
102
102
  Nuxt directly auto-imports files created in defined directories:
103
103
 
104
- - `components/` for [Vue components](/docs/guide/directory-structure/components).
105
- - `composables/` for [Vue composables](/docs/guide/directory-structure/composables).
106
- - `utils/` for helper functions and other utilities.
104
+ - `app/components/` for [Vue components](/docs/guide/directory-structure/app/components).
105
+ - `app/composables/` for [Vue composables](/docs/guide/directory-structure/app/composables).
106
+ - `app/utils/` for helper functions and other utilities.
107
107
 
108
108
  :link-example{to="/docs/examples/features/auto-imports"}
109
109
 
@@ -167,7 +167,7 @@ With this configuration:
167
167
 
168
168
  Nuxt also automatically imports components from your `~/components` directory, although this is configured separately from auto-importing composables and utility functions.
169
169
 
170
- :read-more{to="/docs/guide/directory-structure/components"}
170
+ :read-more{to="/docs/guide/directory-structure/app/components"}
171
171
 
172
172
  To disable auto-importing components from your own `~/components` directory, you can set `components.dirs` to an empty array (though note that this will not affect components added by modules).
173
173
 
@@ -38,7 +38,7 @@ Returning a value from middleware will terminate the request and send the return
38
38
 
39
39
  The Vue and Nuxt instances are created first. Afterward, Nuxt executes its server plugins. This includes:
40
40
  - Built-in plugins, such as Vue Router and `unhead`.
41
- - Custom plugins located in the `plugins/` directory, including those without a suffix (e.g., `myPlugin.ts`) and those with the `.server` suffix (e.g., `myServerPlugin.server.ts`).
41
+ - Custom plugins located in the `app/plugins/` directory, including those without a suffix (e.g., `myPlugin.ts`) and those with the `.server` suffix (e.g., `myServerPlugin.server.ts`).
42
42
 
43
43
  Plugins execute in a specific order and may have dependencies on one another. For more details, including execution order and parallelism, refer to the [Plugins documentation](/docs/guide/directory-structure/plugins).
44
44
 
@@ -70,11 +70,11 @@ In Nuxt, there are three types of middleware:
70
70
 
71
71
  Nuxt executes all global middleware on the initial page load (both on server and client) and then again before any client-side navigation. Named and anonymous middleware are executed only on the routes specified in the middleware property of the page(route) meta defined in the corresponding page components.
72
72
 
73
- For details about each type and examples, see the [Middleware documentation](/docs/guide/directory-structure/middleware).
73
+ For details about each type and examples, see the [Middleware documentation](/docs/guide/directory-structure/app/middleware).
74
74
 
75
75
  Any redirection on the server will result in a `Location:` header being sent to the browser; the browser then makes a fresh request to this new location. All application state will be reset when this happens, unless persisted in a cookie.
76
76
 
77
- :read-more{to="/docs/guide/directory-structure/middleware"}
77
+ :read-more{to="/docs/guide/directory-structure/app/middleware"}
78
78
 
79
79
  ### Step 6: Render Page and Components
80
80
 
@@ -114,7 +114,7 @@ This part of the lifecycle is fully executed in the browser, no matter which Nux
114
114
 
115
115
  This step is similar to the server-side execution and includes both built-in and custom plugins.
116
116
 
117
- Custom plugins in the `plugins/` directory, such as those without a suffix (e.g., `myPlugin.ts`) and with the `.client` suffix (e.g., `myClientPlugin.client.ts`), are executed on the client side.
117
+ Custom plugins in the `app/plugins/` directory, such as those without a suffix (e.g., `myPlugin.ts`) and with the `.client` suffix (e.g., `myClientPlugin.client.ts`), are executed on the client side.
118
118
 
119
119
  ::callout{icon="i-lucide-lightbulb"}
120
120
  After this step, Nuxt calls the [`app:created`](/docs/api/advanced/hooks#app-hooks-runtime) hook, which can be used to execute additional logic.
@@ -130,11 +130,11 @@ This step is the same as the server-side execution and includes the `validate` m
130
130
 
131
131
  Nuxt middleware runs on both the server and the client. If you want certain code to run in specific environments, consider splitting it by using `import.meta.client` for the client and `import.meta.server` for the server.
132
132
 
133
- :read-more{to="/docs/guide/directory-structure/middleware#when-middleware-runs"}
133
+ :read-more{to="/docs/guide/directory-structure/app/middleware#when-middleware-runs"}
134
134
 
135
135
  ### Step 4: Mount Vue Application and Hydration
136
136
 
137
- Calling `app.mount('#__nuxt')` mounts the Vue application to the DOM. If the application uses SSR or SSG mode, Vue performs a hydration step to make the client-side application interactive. During hydration, Vue recreates the application (excluding [Server Components](/docs/guide/directory-structure/components#server-components)), matches each component to its corresponding DOM nodes, and attaches DOM event listeners.
137
+ Calling `app.mount('#__nuxt')` mounts the Vue application to the DOM. If the application uses SSR or SSG mode, Vue performs a hydration step to make the client-side application interactive. During hydration, Vue recreates the application (excluding [Server Components](/docs/guide/directory-structure/app/components#server-components)), matches each component to its corresponding DOM nodes, and attaches DOM event listeners.
138
138
 
139
139
  To ensure proper hydration, it's important to maintain consistency between the data on the server and the client. For API requests, it is recommended to use `useAsyncData`, `useFetch`, or other SSR-friendly composables. These methods ensure that the data fetched on the server side is reused during hydration, avoiding repeated requests. Any new requests should only be triggered after hydration, preventing hydration errors.
140
140
 
@@ -25,13 +25,13 @@ We chose to build Nuxt on top of Vue for these reasons:
25
25
 
26
26
  ### Auto-imports
27
27
 
28
- Every Vue component created in the [`components/`](/docs/guide/directory-structure/components) directory of a Nuxt project will be available in your project without having to import it. If a component is not used anywhere, your production’s code will not include it.
28
+ Every Vue component created in the [`app/components/`](/docs/guide/directory-structure/app/components) directory of a Nuxt project will be available in your project without having to import it. If a component is not used anywhere, your production’s code will not include it.
29
29
 
30
30
  :read-more{to="/docs/guide/concepts/auto-imports"}
31
31
 
32
32
  ### Vue Router
33
33
 
34
- Most applications need multiple pages and a way to navigate between them. This is called **routing**. Nuxt uses a [`pages/`](/docs/guide/directory-structure/pages) directory and naming conventions to directly create routes mapped to your files using the official [Vue Router library](https://router.vuejs.org).
34
+ Most applications need multiple pages and a way to navigate between them. This is called **routing**. Nuxt uses an [`app/pages/`](/docs/guide/directory-structure/app/pages) directory and naming conventions to directly create routes mapped to your files using the official [Vue Router library](https://router.vuejs.org).
35
35
 
36
36
  :read-more{to="/docs/getting-started/routing"}
37
37
 
@@ -92,7 +92,7 @@ const increment = () => count.value++
92
92
  The goal of Nuxt is to provide a great developer experience around the Composition API.
93
93
 
94
94
  - Use auto-imported [Reactivity functions](https://vuejs.org/api/reactivity-core.html) from Vue and Nuxt [built-in composables](/docs/api/composables/use-async-data).
95
- - Write your own auto-imported reusable functions in the [`composables/` directory](/docs/guide/directory-structure/composables).
95
+ - Write your own auto-imported reusable functions in the [`app/composables/` directory](/docs/guide/directory-structure/app/composables).
96
96
 
97
97
  ### TypeScript Support
98
98
 
@@ -23,7 +23,7 @@ Universal rendering allows a Nuxt application to provide quick page load times w
23
23
 
24
24
  It is normal to ask which parts of a Vue file runs on the server and/or the client in universal rendering mode.
25
25
 
26
- ```vue [app.vue]
26
+ ```vue [app/app.vue]
27
27
  <script setup lang="ts">
28
28
  const counter = ref(0); // executes in server and client environments
29
29
 
@@ -42,7 +42,7 @@ const handleClick = () => {
42
42
 
43
43
  On the initial request, the `counter` ref is initialized in the server since it is rendered inside the `<p>` tag. The contents of `handleClick` is never executed here. During hydration in the browser, the `counter` ref is re-initialized. The `handleClick` finally binds itself to the button; Therefore it is reasonable to deduce that the body of `handleClick` will always run in a browser environment.
44
44
 
45
- [Middlewares](/docs/guide/directory-structure/middleware) and [pages](/docs/guide/directory-structure/pages) run in the server and on the client during hydration. [Plugins](/docs/guide/directory-structure/plugins) can be rendered on the server or client or both. [Components](/docs/guide/directory-structure/components) can be forced to run on the client only as well. [Composables](/docs/guide/directory-structure/composables) and [utilities](/docs/guide/directory-structure/utils) are rendered based on the context of their usage.
45
+ [Middlewares](/docs/guide/directory-structure/app/middleware) and [pages](/docs/guide/directory-structure/app/pages) run in the server and on the client during hydration. [Plugins](/docs/guide/directory-structure/plugins) can be rendered on the server or client or both. [Components](/docs/guide/directory-structure/app/components) can be forced to run on the client only as well. [Composables](/docs/guide/directory-structure/app/composables) and [utilities](/docs/guide/directory-structure/app/utils) are rendered based on the context of their usage.
46
46
 
47
47
  **Benefits of server-side rendering:**
48
48
  - **Performance**: Users can get immediate access to the page's content because browsers can display static content much faster than JavaScript-generated content. At the same time, Nuxt preserves the interactivity of a web application during the hydration process.
@@ -70,7 +70,7 @@ Watch a video from Daniel Roe explaining built-in Nuxt aliases.
70
70
  ::
71
71
 
72
72
  ::note
73
- Nitro also [auto-generates types](/docs/guide/concepts/server-engine#typed-api-routes) for API routes. Plus, Nuxt also generates types for globally available components and [auto-imports from your composables](/docs/guide/directory-structure/composables), plus other core functionality.
73
+ Nitro also [auto-generates types](/docs/guide/concepts/server-engine#typed-api-routes) for API routes. Plus, Nuxt also generates types for globally available components and [auto-imports from your composables](/docs/guide/directory-structure/app/composables), plus other core functionality.
74
74
  ::
75
75
 
76
76
  ::note
@@ -13,7 +13,7 @@ Nuxt automatically imports any components in this directory (along with componen
13
13
  ---| AppFooter.vue
14
14
  ```
15
15
 
16
- ```html [app.vue]
16
+ ```html [app/app.vue]
17
17
  <template>
18
18
  <div>
19
19
  <AppHeader />
@@ -65,7 +65,7 @@ If you want to use the Vue `<component :is="someComputedComponent">`{lang=vue} s
65
65
 
66
66
  For example:
67
67
 
68
- ```vue [pages/index.vue]
68
+ ```vue [app/pages/index.vue]
69
69
  <script setup lang="ts">
70
70
  import { SomeComponent } from '#components'
71
71
 
@@ -107,7 +107,7 @@ To dynamically import a component (also known as lazy-loading a component) all y
107
107
 
108
108
  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.
109
109
 
110
- ```vue [pages/index.vue]
110
+ ```vue [app/pages/index.vue]
111
111
  <script setup lang="ts">
112
112
  const show = ref(false)
113
113
  </script>
@@ -141,7 +141,7 @@ Currently Nuxt's built-in lazy hydration only works in single-file components (S
141
141
 
142
142
  Hydrates the component when it becomes visible in the viewport.
143
143
 
144
- ```vue [pages/index.vue]
144
+ ```vue [app/pages/index.vue]
145
145
  <template>
146
146
  <div>
147
147
  <LazyMyComponent hydrate-on-visible />
@@ -163,7 +163,7 @@ Hydrates the component when the browser is idle. This is suitable if you need th
163
163
 
164
164
  You can also pass a number which serves as a max timeout.
165
165
 
166
- ```vue [pages/index.vue]
166
+ ```vue [app/pages/index.vue]
167
167
  <template>
168
168
  <div>
169
169
  <LazyMyComponent hydrate-on-idle />
@@ -179,7 +179,7 @@ Under the hood, this uses Vue's built-in [`hydrateOnIdle` strategy](https://vuej
179
179
 
180
180
  Hydrates the component after a specified interaction (e.g., click, mouseover).
181
181
 
182
- ```vue [pages/index.vue]
182
+ ```vue [app/pages/index.vue]
183
183
  <template>
184
184
  <div>
185
185
  <LazyMyComponent hydrate-on-interaction="mouseover" />
@@ -197,7 +197,7 @@ Under the hood, this uses Vue's built-in [`hydrateOnInteraction` strategy](https
197
197
 
198
198
  Hydrates the component when the window matches a media query.
199
199
 
200
- ```vue [pages/index.vue]
200
+ ```vue [app/pages/index.vue]
201
201
  <template>
202
202
  <div>
203
203
  <LazyMyComponent hydrate-on-media-query="(max-width: 768px)" />
@@ -213,7 +213,7 @@ Under the hood, this uses Vue's built-in [`hydrateOnMediaQuery` strategy](https:
213
213
 
214
214
  Hydrates the component after a specified delay (in milliseconds).
215
215
 
216
- ```vue [pages/index.vue]
216
+ ```vue [app/pages/index.vue]
217
217
  <template>
218
218
  <div>
219
219
  <LazyMyComponent :hydrate-after="2000" />
@@ -225,7 +225,7 @@ Hydrates the component after a specified delay (in milliseconds).
225
225
 
226
226
  Hydrates the component based on a boolean condition.
227
227
 
228
- ```vue [pages/index.vue]
228
+ ```vue [app/pages/index.vue]
229
229
  <template>
230
230
  <div>
231
231
  <LazyMyComponent :hydrate-when="isReady" />
@@ -244,7 +244,7 @@ function myFunction() {
244
244
 
245
245
  Never hydrates the component.
246
246
 
247
- ```vue [pages/index.vue]
247
+ ```vue [app/pages/index.vue]
248
248
  <template>
249
249
  <div>
250
250
  <LazyMyComponent hydrate-never />
@@ -256,7 +256,7 @@ Never hydrates the component.
256
256
 
257
257
  All delayed hydration components emit a `@hydrated` event when they are hydrated.
258
258
 
259
- ```vue [pages/index.vue]
259
+ ```vue [app/pages/index.vue]
260
260
  <template>
261
261
  <div>
262
262
  <LazyMyComponent hydrate-on-visible @hydrated="onHydrate" />
@@ -291,7 +291,7 @@ Delayed hydration can offer performance benefits, but it's essential to use it c
291
291
 
292
292
  You can also explicitly import components from `#components` if you want or need to bypass Nuxt's auto-importing functionality.
293
293
 
294
- ```vue [pages/index.vue]
294
+ ```vue [app/pages/index.vue]
295
295
  <script setup lang="ts">
296
296
  import { NuxtLink, LazyMountainsList } from '#components'
297
297
 
@@ -359,7 +359,7 @@ export default defineNuxtModule({
359
359
  })
360
360
  ```
361
361
 
362
- ```vue [app.vue]
362
+ ```vue [app/app.vue]
363
363
  <template>
364
364
  <div>
365
365
  <!-- the component uses the name we specified and is auto-imported -->
@@ -395,7 +395,7 @@ If a component is meant to be rendered only client-side, you can add the `.clien
395
395
  --| Comments.client.vue
396
396
  ```
397
397
 
398
- ```vue [pages/example.vue]
398
+ ```vue [app/pages/example.vue]
399
399
  <template>
400
400
  <div>
401
401
  <!-- this component will only be rendered on client side -->
@@ -451,7 +451,7 @@ Now you can register server-only components with the `.server` suffix and use th
451
451
  ---| HighlightedMarkdown.server.vue
452
452
  ```
453
453
 
454
- ```vue [pages/example.vue]
454
+ ```vue [app/pages/example.vue]
455
455
  <template>
456
456
  <div>
457
457
  <!--
@@ -489,7 +489,7 @@ This feature needs `experimental.componentIslands.selectiveClient` within your c
489
489
 
490
490
  You can partially hydrate a component by setting a `nuxt-client` attribute on the component you wish to be loaded client-side.
491
491
 
492
- ```vue [components/ServerWithClient.vue]
492
+ ```vue [app/components/ServerWithClient.vue]
493
493
  <template>
494
494
  <div>
495
495
  <HighlightedMarkdown markdown="# Headline" />
@@ -530,7 +530,7 @@ In this case, the `.server` + `.client` components are two 'halves' of a compone
530
530
  ---| Comments.server.vue
531
531
  ```
532
532
 
533
- ```vue [pages/example.vue]
533
+ ```vue [app/pages/example.vue]
534
534
  <template>
535
535
  <div>
536
536
  <!-- this component will render Comments.server on the server then Comments.client once mounted in the browser -->
@@ -592,7 +592,7 @@ export default defineNuxtConfig({
592
592
  })
593
593
  ```
594
594
 
595
- ... and directly use the module components (prefixed with `awesome-`) in our `pages/index.vue`:
595
+ ... and directly use the module components (prefixed with `awesome-`) in our `app/pages/index.vue`:
596
596
 
597
597
  ```vue
598
598
  <template>
@@ -9,7 +9,7 @@ navigation.icon: i-lucide-folder
9
9
 
10
10
  **Method 1:** Using named export
11
11
 
12
- ```js [composables/useFoo.ts]
12
+ ```js [app/composables/useFoo.ts]
13
13
  export const useFoo = () => {
14
14
  return useState('foo', () => 'bar')
15
15
  }
@@ -17,7 +17,7 @@ export const useFoo = () => {
17
17
 
18
18
  **Method 2:** Using default export
19
19
 
20
- ```js [composables/use-foo.ts or composables/useFoo.ts]
20
+ ```js [app/composables/use-foo.ts or composables/useFoo.ts]
21
21
  // It will be available as useFoo() (camelCase of file name without extension)
22
22
  export default function () {
23
23
  return useState('foo', () => 'bar')
@@ -26,7 +26,7 @@ export default function () {
26
26
 
27
27
  **Usage:** You can now use auto imported composable in `.js`, `.ts` and `.vue` files
28
28
 
29
- ```vue [app.vue]
29
+ ```vue [app/app.vue]
30
30
  <script setup lang="ts">
31
31
  const foo = useFoo()
32
32
  </script>
@@ -39,7 +39,7 @@ const foo = useFoo()
39
39
  ```
40
40
 
41
41
  ::note
42
- The `composables/` directory in Nuxt does not provide any additional reactivity capabilities to your code. Instead, any reactivity within composables is achieved using Vue's Composition API mechanisms, such as ref and reactive. Note that reactive code is also not limited to the boundaries of the `composables/` directory. You are free to employ reactivity features wherever they're needed in your application.
42
+ The `app/composables/` directory in Nuxt does not provide any additional reactivity capabilities to your code. Instead, any reactivity within composables is achieved using Vue's Composition API mechanisms, such as ref and reactive. Note that reactive code is also not limited to the boundaries of the `app/composables/` directory. You are free to employ reactivity features wherever they're needed in your application.
43
43
  ::
44
44
 
45
45
  :read-more{to="/docs/guide/concepts/auto-imports"}
@@ -62,7 +62,7 @@ If you create a composable without having the dev server running, TypeScript wil
62
62
 
63
63
  You can use a composable within another composable using auto imports:
64
64
 
65
- ```js [composables/test.ts]
65
+ ```js [app/composables/test.ts]
66
66
  export const useFoo = () => {
67
67
  const nuxtApp = useNuxtApp()
68
68
  const bar = useBar()
@@ -73,7 +73,7 @@ export const useFoo = () => {
73
73
 
74
74
  You can access [plugin injections](/docs/guide/directory-structure/plugins#providing-helpers) from composables:
75
75
 
76
- ```js [composables/test.ts]
76
+ ```js [app/composables/test.ts]
77
77
  export const useHello = () => {
78
78
  const nuxtApp = useNuxtApp()
79
79
  return nuxtApp.$hello
@@ -82,7 +82,7 @@ export const useHello = () => {
82
82
 
83
83
  ## How Files Are Scanned
84
84
 
85
- Nuxt only scans files at the top level of the [`composables/` directory](/docs/guide/directory-structure/composables), e.g.:
85
+ Nuxt only scans files at the top level of the [`app/composables/` directory](/docs/guide/directory-structure/app/composables), e.g.:
86
86
 
87
87
  ```bash [Directory Structure]
88
88
  -| composables/
@@ -92,18 +92,18 @@ Nuxt only scans files at the top level of the [`composables/` directory](/docs/g
92
92
  -----| utils.ts // not scanned
93
93
  ```
94
94
 
95
- Only `composables/index.ts` and `composables/useFoo.ts` would be searched for imports.
95
+ Only `app/composables/index.ts` and `app/composables/useFoo.ts` would be searched for imports.
96
96
 
97
97
  To get auto imports working for nested modules, you could either re-export them (recommended) or configure the scanner to include nested directories:
98
98
 
99
- **Example:** Re-export the composables you need from the `composables/index.ts` file:
99
+ **Example:** Re-export the composables you need from the `app/composables/index.ts` file:
100
100
 
101
- ```ts [composables/index.ts]
101
+ ```ts [app/composables/index.ts]
102
102
  // Enables auto import for this export
103
103
  export { utils } from './nested/utils.ts'
104
104
  ```
105
105
 
106
- **Example:** Scan nested directories inside the `composables/` folder:
106
+ **Example:** Scan nested directories inside the `app/composables/` folder:
107
107
 
108
108
  ```ts twoslash [nuxt.config.ts]
109
109
  export default defineNuxtConfig({
@@ -13,7 +13,7 @@ For best performance, components placed in this directory will be automatically
13
13
 
14
14
  Layouts are enabled by adding [`<NuxtLayout>`](/docs/api/components/nuxt-layout) to your [`app.vue`](/docs/guide/directory-structure/app):
15
15
 
16
- ```vue [app.vue]
16
+ ```vue [app/app.vue]
17
17
  <template>
18
18
  <NuxtLayout>
19
19
  <NuxtPage />
@@ -30,7 +30,7 @@ The layout name is normalized to kebab-case, so `someLayout` becomes `some-layou
30
30
  ::
31
31
 
32
32
  ::note
33
- If no layout is specified, `layouts/default.vue` will be used.
33
+ If no layout is specified, `app/layouts/default.vue` will be used.
34
34
  ::
35
35
 
36
36
  ::important
@@ -45,7 +45,7 @@ Unlike other components, your layouts must have a single root element to allow N
45
45
 
46
46
  Add a `~/layouts/default.vue`:
47
47
 
48
- ```vue [layouts/default.vue]
48
+ ```vue [app/layouts/default.vue]
49
49
  <template>
50
50
  <div>
51
51
  <p>Some default layout content shared across all pages</p>
@@ -74,13 +74,13 @@ definePageMeta({
74
74
  </script>
75
75
  ```
76
76
 
77
- ::read-more{to="/docs/guide/directory-structure/pages#page-metadata"}
77
+ ::read-more{to="/docs/guide/directory-structure/app/pages#page-metadata"}
78
78
  Learn more about `definePageMeta`.
79
79
  ::
80
80
 
81
81
  You can directly override the default layout for all pages using the `name` property of [`<NuxtLayout>`](/docs/api/components/nuxt-layout):
82
82
 
83
- ```vue [app.vue]
83
+ ```vue [app/app.vue]
84
84
  <script setup lang="ts">
85
85
  // You might choose this based on an API call or logged-in status
86
86
  const layout = "custom";
@@ -140,7 +140,7 @@ If you are using pages, you can take full control by setting `layout: false` and
140
140
 
141
141
  ::code-group
142
142
 
143
- ```vue [pages/index.vue]
143
+ ```vue [app/pages/index.vue]
144
144
  <script setup lang="ts">
145
145
  definePageMeta({
146
146
  layout: false,
@@ -158,7 +158,7 @@ definePageMeta({
158
158
  </template>
159
159
  ```
160
160
 
161
- ```vue [layouts/custom.vue]
161
+ ```vue [app/layouts/custom.vue]
162
162
  <template>
163
163
  <div>
164
164
  <header>
@@ -10,8 +10,8 @@ Nuxt provides a customizable **route middleware** framework you can use througho
10
10
  There are three kinds of route middleware:
11
11
 
12
12
  1. Anonymous (or inline) route middleware are defined directly within the page.
13
- 2. Named route middleware, placed in the `middleware/` and automatically loaded via asynchronous import when used on a page.
14
- 3. Global route middleware, placed in the `middleware/` with a `.global` suffix and is run on every route change.
13
+ 2. Named route middleware, placed in the `app/middleware/` and automatically loaded via asynchronous import when used on a page.
14
+ 3. Global route middleware, placed in the `app/middleware/` with a `.global` suffix and is run on every route change.
15
15
 
16
16
  The first two kinds of route middleware can be defined in [`definePageMeta`](/docs/api/utils/define-page-meta).
17
17
 
@@ -74,7 +74,7 @@ Middleware runs in the following order:
74
74
 
75
75
  For example, assuming you have the following middleware and component:
76
76
 
77
- ```bash [middleware/ directory]
77
+ ```bash [app/middleware/ directory]
78
78
  -| middleware/
79
79
  ---| analytics.global.ts
80
80
  ---| setup.global.ts