@nuxt/docs-nightly 4.1.3-29313386.edc02e27 → 4.1.3-29316215.910d159d

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 (165) hide show
  1. package/1.getting-started/01.introduction.md +4 -4
  2. package/1.getting-started/02.installation.md +1 -1
  3. package/1.getting-started/03.configuration.md +25 -25
  4. package/1.getting-started/04.views.md +3 -3
  5. package/1.getting-started/05.assets.md +9 -3
  6. package/1.getting-started/06.styling.md +53 -43
  7. package/1.getting-started/07.routing.md +9 -9
  8. package/1.getting-started/08.seo-meta.md +50 -37
  9. package/1.getting-started/09.transitions.md +38 -33
  10. package/1.getting-started/10.data-fetching.md +61 -53
  11. package/1.getting-started/11.state-management.md +19 -12
  12. package/1.getting-started/12.error-handling.md +17 -15
  13. package/1.getting-started/13.server.md +8 -8
  14. package/1.getting-started/14.layers.md +19 -13
  15. package/1.getting-started/15.prerendering.md +28 -28
  16. package/1.getting-started/16.deployment.md +8 -8
  17. package/1.getting-started/17.testing.md +42 -42
  18. package/1.getting-started/18.upgrade.md +50 -68
  19. package/2.guide/0.index.md +5 -5
  20. package/2.guide/1.directory-structure/0.output.md +1 -1
  21. package/2.guide/1.directory-structure/1.app/1.assets.md +1 -1
  22. package/2.guide/1.directory-structure/1.app/1.components.md +40 -23
  23. package/2.guide/1.directory-structure/1.app/1.composables.md +9 -9
  24. package/2.guide/1.directory-structure/1.app/1.layouts.md +12 -8
  25. package/2.guide/1.directory-structure/1.app/1.middleware.md +23 -17
  26. package/2.guide/1.directory-structure/1.app/1.pages.md +25 -23
  27. package/2.guide/1.directory-structure/1.app/1.plugins.md +17 -17
  28. package/2.guide/1.directory-structure/1.app/1.utils.md +3 -3
  29. package/2.guide/1.directory-structure/1.app/3.app-config.md +7 -7
  30. package/2.guide/1.directory-structure/1.app/3.app.md +3 -3
  31. package/2.guide/1.directory-structure/1.app/3.error.md +4 -4
  32. package/2.guide/1.directory-structure/1.content.md +4 -1
  33. package/2.guide/1.directory-structure/1.modules.md +5 -5
  34. package/2.guide/1.directory-structure/1.public.md +1 -1
  35. package/2.guide/1.directory-structure/1.server.md +30 -30
  36. package/2.guide/1.directory-structure/1.shared.md +3 -3
  37. package/2.guide/1.directory-structure/2.env.md +3 -3
  38. package/2.guide/1.directory-structure/2.nuxtrc.md +1 -1
  39. package/2.guide/1.directory-structure/3.nuxt-config.md +1 -1
  40. package/2.guide/2.concepts/1.auto-imports.md +15 -15
  41. package/2.guide/2.concepts/10.nuxt-lifecycle.md +7 -7
  42. package/2.guide/2.concepts/2.vuejs-development.md +9 -9
  43. package/2.guide/2.concepts/3.rendering.md +17 -15
  44. package/2.guide/2.concepts/4.server-engine.md +1 -1
  45. package/2.guide/2.concepts/5.modules.md +3 -3
  46. package/2.guide/2.concepts/7.esm.md +16 -14
  47. package/2.guide/2.concepts/8.typescript.md +4 -4
  48. package/2.guide/3.going-further/1.events.md +3 -3
  49. package/2.guide/3.going-further/1.experimental-features.md +238 -77
  50. package/2.guide/3.going-further/1.features.md +44 -9
  51. package/2.guide/3.going-further/1.internals.md +15 -15
  52. package/2.guide/3.going-further/10.runtime-config.md +8 -8
  53. package/2.guide/3.going-further/11.nightly-release-channel.md +1 -1
  54. package/2.guide/3.going-further/2.hooks.md +11 -11
  55. package/2.guide/3.going-further/3.modules.md +83 -81
  56. package/2.guide/3.going-further/4.kit.md +5 -5
  57. package/2.guide/3.going-further/6.nuxt-app.md +4 -4
  58. package/2.guide/3.going-further/7.layers.md +51 -42
  59. package/2.guide/3.going-further/9.debugging.md +2 -2
  60. package/2.guide/4.recipes/1.custom-routing.md +19 -19
  61. package/2.guide/4.recipes/2.vite-plugin.md +3 -3
  62. package/2.guide/4.recipes/3.custom-usefetch.md +10 -10
  63. package/2.guide/4.recipes/4.sessions-and-authentication.md +34 -20
  64. package/2.guide/5.best-practices/performance.md +13 -13
  65. package/3.api/1.components/1.client-only.md +6 -3
  66. package/3.api/1.components/1.nuxt-client-fallback.md +10 -7
  67. package/3.api/1.components/11.teleports.md +5 -2
  68. package/3.api/1.components/12.nuxt-route-announcer.md +7 -7
  69. package/3.api/1.components/13.nuxt-time.md +44 -17
  70. package/3.api/1.components/2.nuxt-page.md +4 -4
  71. package/3.api/1.components/3.nuxt-layout.md +13 -8
  72. package/3.api/1.components/4.nuxt-link.md +40 -20
  73. package/3.api/1.components/5.nuxt-loading-indicator.md +1 -1
  74. package/3.api/1.components/6.nuxt-error-boundary.md +12 -10
  75. package/3.api/2.composables/on-prehydrate.md +2 -2
  76. package/3.api/2.composables/use-app-config.md +1 -1
  77. package/3.api/2.composables/use-async-data.md +14 -14
  78. package/3.api/2.composables/use-cookie.md +27 -19
  79. package/3.api/2.composables/use-error.md +2 -2
  80. package/3.api/2.composables/use-fetch.md +17 -17
  81. package/3.api/2.composables/use-head-safe.md +5 -5
  82. package/3.api/2.composables/use-head.md +3 -3
  83. package/3.api/2.composables/use-hydration.md +5 -5
  84. package/3.api/2.composables/use-lazy-async-data.md +2 -2
  85. package/3.api/2.composables/use-lazy-fetch.md +2 -2
  86. package/3.api/2.composables/use-loading-indicator.md +10 -10
  87. package/3.api/2.composables/use-nuxt-app.md +10 -10
  88. package/3.api/2.composables/use-nuxt-data.md +7 -7
  89. package/3.api/2.composables/use-preview-mode.md +12 -15
  90. package/3.api/2.composables/use-request-fetch.md +1 -1
  91. package/3.api/2.composables/use-request-headers.md +3 -3
  92. package/3.api/2.composables/use-response-header.md +7 -8
  93. package/3.api/2.composables/use-route-announcer.md +3 -3
  94. package/3.api/2.composables/use-router.md +6 -4
  95. package/3.api/2.composables/use-runtime-config.md +11 -11
  96. package/3.api/2.composables/use-runtime-hook.md +1 -1
  97. package/3.api/2.composables/use-seo-meta.md +3 -3
  98. package/3.api/2.composables/use-server-seo-meta.md +3 -3
  99. package/3.api/2.composables/use-state.md +4 -4
  100. package/3.api/3.utils/$fetch.md +6 -4
  101. package/3.api/3.utils/abort-navigation.md +2 -2
  102. package/3.api/3.utils/add-route-middleware.md +3 -3
  103. package/3.api/3.utils/call-once.md +5 -5
  104. package/3.api/3.utils/clear-error.md +2 -2
  105. package/3.api/3.utils/clear-nuxt-data.md +2 -2
  106. package/3.api/3.utils/clear-nuxt-state.md +2 -2
  107. package/3.api/3.utils/create-error.md +2 -2
  108. package/3.api/3.utils/define-lazy-hydration-component.md +13 -13
  109. package/3.api/3.utils/define-nuxt-component.md +5 -5
  110. package/3.api/3.utils/define-nuxt-plugin.md +12 -12
  111. package/3.api/3.utils/define-nuxt-route-middleware.md +2 -2
  112. package/3.api/3.utils/define-page-meta.md +16 -16
  113. package/3.api/3.utils/define-route-rules.md +5 -5
  114. package/3.api/3.utils/navigate-to.md +10 -10
  115. package/3.api/3.utils/preload-components.md +1 -1
  116. package/3.api/3.utils/preload-route-components.md +2 -2
  117. package/3.api/3.utils/prerender-routes.md +2 -2
  118. package/3.api/3.utils/refresh-cookie.md +4 -4
  119. package/3.api/3.utils/refresh-nuxt-data.md +10 -5
  120. package/3.api/3.utils/reload-nuxt-app.md +3 -3
  121. package/3.api/3.utils/set-response-status.md +2 -2
  122. package/3.api/3.utils/show-error.md +3 -3
  123. package/3.api/3.utils/update-app-config.md +3 -2
  124. package/3.api/4.commands/generate.md +1 -1
  125. package/3.api/4.commands/prepare.md +4 -0
  126. package/3.api/4.commands/typecheck.md +1 -1
  127. package/3.api/5.kit/1.modules.md +36 -36
  128. package/3.api/5.kit/10.templates.md +8 -6
  129. package/3.api/5.kit/11.nitro.md +62 -62
  130. package/3.api/5.kit/12.resolving.md +2 -2
  131. package/3.api/5.kit/14.builder.md +1 -0
  132. package/3.api/5.kit/15.examples.md +2 -2
  133. package/3.api/5.kit/16.layers.md +26 -26
  134. package/3.api/5.kit/3.compatibility.md +12 -12
  135. package/3.api/5.kit/4.autoimports.md +12 -12
  136. package/3.api/5.kit/5.components.md +5 -5
  137. package/3.api/5.kit/6.context.md +3 -3
  138. package/3.api/5.kit/7.pages.md +4 -4
  139. package/3.api/5.kit/8.layout.md +1 -1
  140. package/3.api/5.kit/9.plugins.md +5 -4
  141. package/3.api/6.advanced/1.hooks.md +1 -1
  142. package/3.api/6.advanced/2.import-meta.md +3 -3
  143. package/3.api/6.nuxt-config.md +299 -864
  144. package/3.api/index.md +7 -7
  145. package/5.community/4.contribution.md +5 -5
  146. package/5.community/5.framework-contribution.md +1 -1
  147. package/6.bridge/1.overview.md +1 -1
  148. package/6.bridge/10.configuration.md +2 -1
  149. package/6.bridge/2.typescript.md +2 -2
  150. package/6.bridge/3.bridge-composition-api.md +4 -4
  151. package/6.bridge/4.plugins-and-middleware.md +5 -5
  152. package/6.bridge/5.nuxt3-compatible-api.md +12 -9
  153. package/6.bridge/6.meta.md +15 -14
  154. package/6.bridge/8.nitro.md +2 -2
  155. package/6.bridge/9.vite.md +3 -3
  156. package/7.migration/10.bundling.md +1 -1
  157. package/7.migration/11.server.md +3 -3
  158. package/7.migration/2.configuration.md +18 -16
  159. package/7.migration/20.module-authors.md +1 -1
  160. package/7.migration/4.meta.md +18 -15
  161. package/7.migration/5.plugins-and-middleware.md +8 -8
  162. package/7.migration/6.pages-and-layouts.md +20 -16
  163. package/7.migration/7.component-options.md +7 -7
  164. package/7.migration/8.runtime-config.md +4 -4
  165. package/package.json +1 -1
@@ -44,7 +44,7 @@ Overall, server-side rendering can provide a faster and more efficient user expe
44
44
  As Nuxt is a versatile framework, it gives you the possibility to statically render your whole application to a static hosting with `nuxt generate`,
45
45
  disable SSR globally with the `ssr: false` option or leverage hybrid rendering by setting up the `routeRules` option.
46
46
 
47
- :read-more{title="Nuxt rendering modes" to="/docs/guide/concepts/rendering"}
47
+ :read-more{title="Nuxt rendering modes" to="/docs/4.x/guide/concepts/rendering"}
48
48
 
49
49
  ### Server engine
50
50
 
@@ -54,19 +54,19 @@ In development, it uses Rollup and Node.js workers for your server code and cont
54
54
 
55
55
  In production, Nitro builds your app and server into one universal `.output` directory. This output is light: minified and removed from any Node.js modules (except polyfills). You can deploy this output on any system supporting JavaScript, from Node.js, Serverless, Workers, Edge-side rendering or purely static.
56
56
 
57
- :read-more{title="Nuxt server engine" to="/docs/guide/concepts/server-engine"}
57
+ :read-more{title="Nuxt server engine" to="/docs/4.x/guide/concepts/server-engine"}
58
58
 
59
59
  ### Production-ready
60
60
 
61
61
  A Nuxt application can be deployed on a Node or Deno server, pre-rendered to be hosted in static environments, or deployed to serverless and edge providers.
62
62
 
63
- :read-more{title="Deployment section" to="/docs/getting-started/deployment"}
63
+ :read-more{title="Deployment section" to="/docs/4.x/getting-started/deployment"}
64
64
 
65
65
  ### Modular
66
66
 
67
67
  A module system allows you to extend Nuxt with custom features and integrations with third-party services.
68
68
 
69
- :read-more{title="Nuxt Modules Concept" to="/docs/guide/concepts/modules"}
69
+ :read-more{title="Nuxt Modules Concept" to="/docs/4.x/guide/concepts/modules"}
70
70
 
71
71
  ### Architecture
72
72
 
@@ -115,4 +115,4 @@ Well done! A browser window should automatically open for <http://localhost:3000
115
115
 
116
116
  Now that you've created your Nuxt project, you are ready to start building your application.
117
117
 
118
- :read-more{title="Nuxt Concepts" to="/docs/guide/concepts"}
118
+ :read-more{title="Nuxt Concepts" to="/docs/4.x/guide/concepts"}
@@ -20,7 +20,7 @@ export default defineNuxtConfig({
20
20
 
21
21
  This file will often be mentioned in the documentation, for example to add custom scripts, register modules or change rendering modes.
22
22
 
23
- ::read-more{to="/docs/api/configuration/nuxt-config"}
23
+ ::read-more{to="/docs/4.x/api/configuration/nuxt-config"}
24
24
  Every option is described in the **Configuration Reference**.
25
25
  ::
26
26
 
@@ -36,16 +36,16 @@ You can configure fully typed, per-environment overrides in your nuxt.config
36
36
  export default defineNuxtConfig({
37
37
  $production: {
38
38
  routeRules: {
39
- '/**': { isr: true }
40
- }
39
+ '/**': { isr: true },
40
+ },
41
41
  },
42
42
  $development: {
43
43
  //
44
44
  },
45
45
  $env: {
46
46
  staging: {
47
- //
48
- }
47
+ //
48
+ },
49
49
  },
50
50
  })
51
51
  ```
@@ -75,9 +75,9 @@ export default defineNuxtConfig({
75
75
  apiSecret: '123',
76
76
  // Keys within public are also exposed client-side
77
77
  public: {
78
- apiBase: '/api'
79
- }
80
- }
78
+ apiBase: '/api',
79
+ },
80
+ },
81
81
  })
82
82
  ```
83
83
 
@@ -96,7 +96,7 @@ const runtimeConfig = useRuntimeConfig()
96
96
  </script>
97
97
  ```
98
98
 
99
- :read-more{to="/docs/guide/going-further/runtime-config"}
99
+ :read-more{to="/docs/4.x/guide/going-further/runtime-config"}
100
100
 
101
101
  ## App Configuration
102
102
 
@@ -110,9 +110,9 @@ export default defineAppConfig({
110
110
  theme: {
111
111
  dark: true,
112
112
  colors: {
113
- primary: '#ff0000'
114
- }
115
- }
113
+ primary: '#ff0000',
114
+ },
115
+ },
116
116
  })
117
117
  ```
118
118
 
@@ -124,7 +124,7 @@ const appConfig = useAppConfig()
124
124
  </script>
125
125
  ```
126
126
 
127
- :read-more{to="/docs/guide/directory-structure/app-config"}
127
+ :read-more{to="/docs/4.x/guide/directory-structure/app-config"}
128
128
 
129
129
  ## `runtimeConfig` vs. `app.config`
130
130
 
@@ -178,16 +178,16 @@ If you need to pass options to `@vitejs/plugin-vue` or `@vitejs/plugin-vue-jsx`,
178
178
  export default defineNuxtConfig({
179
179
  vite: {
180
180
  vue: {
181
- customElement: true
181
+ customElement: true,
182
182
  },
183
183
  vueJsx: {
184
- mergeProps: true
185
- }
186
- }
184
+ mergeProps: true,
185
+ },
186
+ },
187
187
  })
188
188
  ```
189
189
 
190
- :read-more{to="/docs/api/configuration/nuxt-config#vue"}
190
+ :read-more{to="/docs/4.x/api/configuration/nuxt-config#vue"}
191
191
 
192
192
  ### With webpack
193
193
 
@@ -199,13 +199,13 @@ export default defineNuxtConfig({
199
199
  loaders: {
200
200
  vue: {
201
201
  hotReload: true,
202
- }
203
- }
204
- }
202
+ },
203
+ },
204
+ },
205
205
  })
206
206
  ```
207
207
 
208
- :read-more{to="/docs/api/configuration/nuxt-config#loaders"}
208
+ :read-more{to="/docs/4.x/api/configuration/nuxt-config#loaders"}
209
209
 
210
210
  ### Enabling Experimental Vue Features
211
211
 
@@ -214,8 +214,8 @@ You may need to enable experimental features in Vue, such as `propsDestructure`.
214
214
  ```ts twoslash [nuxt.config.ts]
215
215
  export default defineNuxtConfig({
216
216
  vue: {
217
- propsDestructure: true
218
- }
217
+ propsDestructure: true,
218
+ },
219
219
  })
220
220
  ```
221
221
 
@@ -223,4 +223,4 @@ export default defineNuxtConfig({
223
223
 
224
224
  Since Nuxt 3.9 and Vue 3.4, `reactivityTransform` has been moved from Vue to Vue Macros which has a [Nuxt integration](https://vue-macros.dev/guide/nuxt-integration.html).
225
225
 
226
- :read-more{to="/docs/api/configuration/nuxt-config#vue-1"}
226
+ :read-more{to="/docs/4.x/api/configuration/nuxt-config#vue-1"}
@@ -13,7 +13,7 @@ By default, Nuxt will treat this file as the **entrypoint** and render its conte
13
13
  ```vue [app/app.vue]
14
14
  <template>
15
15
  <div>
16
- <h1>Welcome to the homepage</h1>
16
+ <h1>Welcome to the homepage</h1>
17
17
  </div>
18
18
  </template>
19
19
  ```
@@ -82,7 +82,7 @@ To use pages, create an `app/pages/index.vue` file and add `<NuxtPage />` compon
82
82
 
83
83
  ::
84
84
 
85
- :read-more{title="Routing Section" to="/docs/getting-started/routing"}
85
+ :read-more{title="Routing Section" to="/docs/4.x/getting-started/routing"}
86
86
 
87
87
  ## Layouts
88
88
 
@@ -162,4 +162,4 @@ export default defineNitroPlugin((nitroApp) => {
162
162
  })
163
163
  ```
164
164
 
165
- :read-more{to="/docs/guide/going-further/hooks"}
165
+ :read-more{to="/docs/4.x/guide/going-further/hooks"}
@@ -21,7 +21,10 @@ For example, referencing an image file in the `public/img/` directory, available
21
21
 
22
22
  ```vue [app/app.vue]
23
23
  <template>
24
- <img src="/img/nuxt.png" alt="Discover Nuxt" />
24
+ <img
25
+ src="/img/nuxt.png"
26
+ alt="Discover Nuxt"
27
+ >
25
28
  </template>
26
29
  ```
27
30
 
@@ -39,10 +42,13 @@ For example, referencing an image file that will be processed if a build tool is
39
42
 
40
43
  ```vue [app/app.vue]
41
44
  <template>
42
- <img src="~/assets/img/nuxt.png" alt="Discover Nuxt" />
45
+ <img
46
+ src="~/assets/img/nuxt.png"
47
+ alt="Discover Nuxt"
48
+ >
43
49
  </template>
44
50
  ```
45
51
 
46
52
  ::note
47
- Nuxt won't serve files in the [`app/assets/`](/docs/4.x/guide/directory-structure/app/assets) directory at a static URL like `/assets/my-file.png`. If you need a static URL, use the [`public/`](/docs/getting-started/assets#public-directory) directory.
53
+ Nuxt won't serve files in the [`app/assets/`](/docs/4.x/guide/directory-structure/app/assets) directory at a static URL like `/assets/my-file.png`. If you need a static URL, use the [`public/`](/docs/4.x/getting-started/assets#public-directory) directory.
48
54
  ::
@@ -41,7 +41,7 @@ The natural place for your stylesheets is the [`app/assets/` directory](/docs/4.
41
41
 
42
42
  ```ts [nuxt.config.ts]
43
43
  export default defineNuxtConfig({
44
- css: ['~/assets/css/main.css']
44
+ css: ['~/assets/css/main.css'],
45
45
  })
46
46
  ```
47
47
 
@@ -113,7 +113,7 @@ The package can also be referenced as a string in the css property of your Nuxt
113
113
 
114
114
  ```ts [nuxt.config.ts]
115
115
  export default defineNuxtConfig({
116
- css: ['animate.css']
116
+ css: ['animate.css'],
117
117
  })
118
118
  ```
119
119
 
@@ -127,9 +127,9 @@ You can manipulate the head with the [`app.head`](/docs/4.x/api/nuxt-config#head
127
127
  export default defineNuxtConfig({
128
128
  app: {
129
129
  head: {
130
- link: [{ rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css' }]
131
- }
132
- }
130
+ link: [{ rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css' }],
131
+ },
132
+ },
133
133
  })
134
134
  ```
135
135
 
@@ -137,11 +137,11 @@ export default defineNuxtConfig({
137
137
 
138
138
  You can use the useHead composable to dynamically set a value in your head in your code.
139
139
 
140
- :read-more{to="/docs/api/composables/use-head"}
140
+ :read-more{to="/docs/4.x/api/composables/use-head"}
141
141
 
142
142
  ```ts twoslash
143
143
  useHead({
144
- link: [{ rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css' }]
144
+ link: [{ rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css' }],
145
145
  })
146
146
  ```
147
147
 
@@ -198,7 +198,7 @@ Alternatively, you can use the `css` property of your Nuxt configuration.
198
198
 
199
199
  ```ts twoslash [nuxt.config.ts]
200
200
  export default defineNuxtConfig({
201
- css: ['~/assets/scss/main.scss']
201
+ css: ['~/assets/scss/main.scss'],
202
202
  })
203
203
  ```
204
204
 
@@ -234,11 +234,11 @@ export default defineNuxtConfig({
234
234
  css: {
235
235
  preprocessorOptions: {
236
236
  scss: {
237
- additionalData: '@use "~/assets/_colors.scss" as *;'
238
- }
239
- }
240
- }
241
- }
237
+ additionalData: '@use "~/assets/_colors.scss" as *;',
238
+ },
239
+ },
240
+ },
241
+ },
242
242
  })
243
243
  ```
244
244
 
@@ -248,11 +248,11 @@ export default defineNuxtConfig({
248
248
  css: {
249
249
  preprocessorOptions: {
250
250
  sass: {
251
- additionalData: '@use "~/assets/_colors.sass" as *\n'
252
- }
253
- }
254
- }
255
- }
251
+ additionalData: '@use "~/assets/_colors.sass" as *\n',
252
+ },
253
+ },
254
+ },
255
+ },
256
256
  })
257
257
  ```
258
258
 
@@ -267,13 +267,12 @@ Vite has made available an [experimental option](https://vite.dev/config/shared-
267
267
  You can enable this in your `nuxt.config`:
268
268
 
269
269
  ```ts
270
-
271
270
  export default defineNuxtConfig({
272
271
  vite: {
273
272
  css: {
274
- preprocessorMaxWorkers: true // number of CPUs minus 1
275
- }
276
- }
273
+ preprocessorMaxWorkers: true, // number of CPUs minus 1
274
+ },
275
+ },
277
276
  })
278
277
  ```
279
278
 
@@ -298,14 +297,17 @@ You can leverage Vue SFC features to style your components with class and style
298
297
  const isActive = ref(true)
299
298
  const hasError = ref(false)
300
299
  const classObject = reactive({
301
- active: true,
302
- 'text-danger': false
300
+ 'active': true,
301
+ 'text-danger': false,
303
302
  })
304
303
  </script>
305
304
 
306
305
  <template>
307
- <div class="static" :class="{ active: isActive, 'text-danger': hasError }"></div>
308
- <div :class="classObject"></div>
306
+ <div
307
+ class="static"
308
+ :class="{ 'active': isActive, 'text-danger': hasError }"
309
+ />
310
+ <div :class="classObject" />
309
311
  </template>
310
312
  ```
311
313
 
@@ -315,13 +317,13 @@ const isActive = ref(true)
315
317
  const error = ref(null)
316
318
 
317
319
  const classObject = computed(() => ({
318
- active: isActive.value && !error.value,
319
- 'text-danger': error.value && error.value.type === 'fatal'
320
+ 'active': isActive.value && !error.value,
321
+ 'text-danger': error.value && error.value.type === 'fatal',
320
322
  }))
321
323
  </script>
322
324
 
323
325
  <template>
324
- <div :class="classObject"></div>
326
+ <div :class="classObject" />
325
327
  </template>
326
328
  ```
327
329
 
@@ -332,7 +334,7 @@ const errorClass = ref('text-danger')
332
334
  </script>
333
335
 
334
336
  <template>
335
- <div :class="[{ active: isActive }, errorClass]"></div>
337
+ <div :class="[{ active: isActive }, errorClass]" />
336
338
  </template>
337
339
  ```
338
340
 
@@ -344,9 +346,9 @@ const styleObject = reactive({ color: 'red', fontSize: '13px' })
344
346
  </script>
345
347
 
346
348
  <template>
347
- <div :style="{ color: activeColor, fontSize: fontSize + 'px' }"></div>
348
- <div :style="[baseStyles, overridingStyles]"></div>
349
- <div :style="styleObject"></div>
349
+ <div :style="{ color: activeColor, fontSize: fontSize + 'px' }" />
350
+ <div :style="[baseStyles, overridingStyles]" />
351
+ <div :style="styleObject" />
350
352
  </template>
351
353
  ```
352
354
 
@@ -361,11 +363,13 @@ The binding will be dynamic, meaning that if the variable value changes, the sty
361
363
 
362
364
  ```vue
363
365
  <script setup lang="ts">
364
- const color = ref("red")
366
+ const color = ref('red')
365
367
  </script>
366
368
 
367
369
  <template>
368
- <div class="text">hello</div>
370
+ <div class="text">
371
+ hello
372
+ </div>
369
373
  </template>
370
374
 
371
375
  <style>
@@ -381,7 +385,9 @@ The scoped attribute allows you to style components in isolation. The styles dec
381
385
 
382
386
  ```vue
383
387
  <template>
384
- <div class="example">hi</div>
388
+ <div class="example">
389
+ hi
390
+ </div>
385
391
  </template>
386
392
 
387
393
  <style scoped>
@@ -397,7 +403,9 @@ You can use [CSS Modules](https://github.com/css-modules/css-modules) with the m
397
403
 
398
404
  ```vue
399
405
  <template>
400
- <p :class="$style.red">This should be red</p>
406
+ <p :class="$style.red">
407
+ This should be red
408
+ </p>
401
409
  </template>
402
410
 
403
411
  <style module>
@@ -451,9 +459,9 @@ export default defineNuxtConfig({
451
459
  postcss: {
452
460
  plugins: {
453
461
  'postcss-nested': {},
454
- 'postcss-custom-media': {}
455
- }
456
- }
462
+ 'postcss-custom-media': {},
463
+ },
464
+ },
457
465
  })
458
466
  ```
459
467
 
@@ -492,7 +500,7 @@ Use different styles for different layouts.
492
500
  </style>
493
501
  ```
494
502
 
495
- :read-more{to="/docs/guide/directory-structure/app/layouts"}
503
+ :read-more{to="/docs/4.x/guide/directory-structure/app/layouts"}
496
504
 
497
505
  ## Third Party Libraries And Modules
498
506
 
@@ -523,7 +531,7 @@ If you are using [UnoCSS](https://unocss.dev/integrations/nuxt), note that it co
523
531
 
524
532
  Nuxt comes with the same `<Transition>` element that Vue has, and also has support for the experimental [View Transitions API](/docs/4.x/getting-started/transitions#view-transitions-api-experimental).
525
533
 
526
- :read-more{to="/docs/getting-started/transitions"}
534
+ :read-more{to="/docs/4.x/getting-started/transitions"}
527
535
 
528
536
  ### Font Advanced Optimization
529
537
 
@@ -558,7 +566,9 @@ export default defineNuxtConfig({
558
566
  // start from the end of the array and go to the beginning
559
567
  for (let i = css.length - 1; i >= 0; i--) {
560
568
  // if it starts with 'entry', remove it from the list
561
- if (css[i].startsWith('entry')) css.splice(i, 1)
569
+ if (css[i].startsWith('entry')) {
570
+ css.splice(i, 1)
571
+ }
562
572
  }
563
573
  }
564
574
  },
@@ -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/app/pages"}
46
+ :read-more{to="/docs/4.x/guide/directory-structure/app/pages"}
47
47
 
48
48
  ## Navigation
49
49
 
@@ -65,7 +65,7 @@ When a [`<NuxtLink>`](/docs/4.x/api/components/nuxt-link) enters the viewport on
65
65
  </template>
66
66
  ```
67
67
 
68
- :read-more{to="/docs/api/components/nuxt-link"}
68
+ :read-more{to="/docs/4.x/api/components/nuxt-link"}
69
69
 
70
70
  ## Route Parameters
71
71
 
@@ -80,7 +80,7 @@ console.log(route.params.id)
80
80
  </script>
81
81
  ```
82
82
 
83
- :read-more{to="/docs/api/composables/use-route"}
83
+ :read-more{to="/docs/4.x/api/composables/use-route"}
84
84
 
85
85
  ## Route Middleware
86
86
 
@@ -101,7 +101,7 @@ Example of an `auth` middleware protecting the `/dashboard` page:
101
101
  ::code-group
102
102
 
103
103
  ```ts twoslash [middleware/auth.ts]
104
- function isAuthenticated(): boolean { return false }
104
+ function isAuthenticated (): boolean { return false }
105
105
  // ---cut---
106
106
  export default defineNuxtRouteMiddleware((to, from) => {
107
107
  // isAuthenticated() is an example method verifying if a user is authenticated
@@ -114,7 +114,7 @@ export default defineNuxtRouteMiddleware((to, from) => {
114
114
  ```vue twoslash [pages/dashboard.vue]
115
115
  <script setup lang="ts">
116
116
  definePageMeta({
117
- middleware: 'auth'
117
+ middleware: 'auth',
118
118
  })
119
119
  </script>
120
120
 
@@ -125,7 +125,7 @@ definePageMeta({
125
125
 
126
126
  ::
127
127
 
128
- :read-more{to="/docs/guide/directory-structure/app/middleware"}
128
+ :read-more{to="/docs/4.x/guide/directory-structure/app/middleware"}
129
129
 
130
130
  ## Route Validation
131
131
 
@@ -138,12 +138,12 @@ If you have a more complex use case, then you can use anonymous route middleware
138
138
  ```vue twoslash [pages/posts/[id\\].vue]
139
139
  <script setup lang="ts">
140
140
  definePageMeta({
141
- validate: async (route) => {
141
+ validate (route) {
142
142
  // Check if the id is made up of digits
143
143
  return typeof route.params.id === 'string' && /^\d+$/.test(route.params.id)
144
- }
144
+ },
145
145
  })
146
146
  </script>
147
147
  ```
148
148
 
149
- :read-more{to="/docs/api/utils/define-page-meta"}
149
+ :read-more{to="/docs/4.x/api/utils/define-page-meta"}