@nuxt/docs-nightly 4.1.3-29314777.50febbbb → 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 (139) hide show
  1. package/1.getting-started/03.configuration.md +19 -19
  2. package/1.getting-started/04.views.md +1 -1
  3. package/1.getting-started/05.assets.md +8 -2
  4. package/1.getting-started/06.styling.md +50 -40
  5. package/1.getting-started/07.routing.md +4 -4
  6. package/1.getting-started/08.seo-meta.md +46 -33
  7. package/1.getting-started/09.transitions.md +38 -33
  8. package/1.getting-started/10.data-fetching.md +47 -39
  9. package/1.getting-started/11.state-management.md +15 -8
  10. package/1.getting-started/12.error-handling.md +6 -4
  11. package/1.getting-started/13.server.md +3 -3
  12. package/1.getting-started/14.layers.md +18 -12
  13. package/1.getting-started/15.prerendering.md +24 -24
  14. package/1.getting-started/16.deployment.md +7 -7
  15. package/1.getting-started/17.testing.md +41 -41
  16. package/1.getting-started/18.upgrade.md +48 -66
  17. package/2.guide/1.directory-structure/1.app/1.components.md +36 -19
  18. package/2.guide/1.directory-structure/1.app/1.composables.md +7 -7
  19. package/2.guide/1.directory-structure/1.app/1.layouts.md +9 -5
  20. package/2.guide/1.directory-structure/1.app/1.middleware.md +20 -14
  21. package/2.guide/1.directory-structure/1.app/1.pages.md +19 -17
  22. package/2.guide/1.directory-structure/1.app/1.plugins.md +17 -17
  23. package/2.guide/1.directory-structure/1.app/1.utils.md +1 -1
  24. package/2.guide/1.directory-structure/1.app/3.app-config.md +6 -6
  25. package/2.guide/1.directory-structure/1.app/3.error.md +4 -4
  26. package/2.guide/1.directory-structure/1.content.md +4 -1
  27. package/2.guide/1.directory-structure/1.modules.md +4 -4
  28. package/2.guide/1.directory-structure/1.public.md +1 -1
  29. package/2.guide/1.directory-structure/1.server.md +28 -28
  30. package/2.guide/1.directory-structure/1.shared.md +1 -1
  31. package/2.guide/2.concepts/1.auto-imports.md +11 -11
  32. package/2.guide/2.concepts/2.vuejs-development.md +5 -5
  33. package/2.guide/2.concepts/3.rendering.md +14 -12
  34. package/2.guide/2.concepts/5.modules.md +2 -2
  35. package/2.guide/2.concepts/7.esm.md +14 -12
  36. package/2.guide/2.concepts/8.typescript.md +4 -4
  37. package/2.guide/3.going-further/1.events.md +2 -2
  38. package/2.guide/3.going-further/1.experimental-features.md +234 -73
  39. package/2.guide/3.going-further/1.features.md +44 -9
  40. package/2.guide/3.going-further/1.internals.md +15 -15
  41. package/2.guide/3.going-further/10.runtime-config.md +7 -7
  42. package/2.guide/3.going-further/2.hooks.md +8 -8
  43. package/2.guide/3.going-further/3.modules.md +76 -74
  44. package/2.guide/3.going-further/4.kit.md +3 -3
  45. package/2.guide/3.going-further/6.nuxt-app.md +1 -1
  46. package/2.guide/3.going-further/7.layers.md +50 -41
  47. package/2.guide/3.going-further/9.debugging.md +2 -2
  48. package/2.guide/4.recipes/1.custom-routing.md +19 -19
  49. package/2.guide/4.recipes/2.vite-plugin.md +3 -3
  50. package/2.guide/4.recipes/3.custom-usefetch.md +9 -9
  51. package/2.guide/4.recipes/4.sessions-and-authentication.md +33 -19
  52. package/2.guide/5.best-practices/performance.md +8 -8
  53. package/3.api/1.components/1.client-only.md +6 -3
  54. package/3.api/1.components/1.nuxt-client-fallback.md +9 -6
  55. package/3.api/1.components/11.teleports.md +4 -1
  56. package/3.api/1.components/12.nuxt-route-announcer.md +7 -7
  57. package/3.api/1.components/13.nuxt-time.md +44 -17
  58. package/3.api/1.components/2.nuxt-page.md +2 -2
  59. package/3.api/1.components/3.nuxt-layout.md +9 -4
  60. package/3.api/1.components/4.nuxt-link.md +38 -18
  61. package/3.api/1.components/6.nuxt-error-boundary.md +11 -9
  62. package/3.api/2.composables/on-prehydrate.md +2 -2
  63. package/3.api/2.composables/use-async-data.md +11 -11
  64. package/3.api/2.composables/use-cookie.md +26 -18
  65. package/3.api/2.composables/use-error.md +1 -1
  66. package/3.api/2.composables/use-fetch.md +13 -13
  67. package/3.api/2.composables/use-head-safe.md +5 -5
  68. package/3.api/2.composables/use-head.md +2 -2
  69. package/3.api/2.composables/use-hydration.md +5 -5
  70. package/3.api/2.composables/use-loading-indicator.md +10 -10
  71. package/3.api/2.composables/use-nuxt-app.md +9 -9
  72. package/3.api/2.composables/use-nuxt-data.md +7 -7
  73. package/3.api/2.composables/use-preview-mode.md +12 -15
  74. package/3.api/2.composables/use-request-fetch.md +1 -1
  75. package/3.api/2.composables/use-request-headers.md +3 -3
  76. package/3.api/2.composables/use-response-header.md +7 -8
  77. package/3.api/2.composables/use-route-announcer.md +3 -3
  78. package/3.api/2.composables/use-router.md +5 -3
  79. package/3.api/2.composables/use-runtime-config.md +6 -6
  80. package/3.api/2.composables/use-runtime-hook.md +1 -1
  81. package/3.api/2.composables/use-seo-meta.md +1 -1
  82. package/3.api/2.composables/use-server-seo-meta.md +1 -1
  83. package/3.api/2.composables/use-state.md +3 -3
  84. package/3.api/3.utils/$fetch.md +5 -3
  85. package/3.api/3.utils/abort-navigation.md +2 -2
  86. package/3.api/3.utils/add-route-middleware.md +3 -3
  87. package/3.api/3.utils/call-once.md +3 -3
  88. package/3.api/3.utils/clear-error.md +1 -1
  89. package/3.api/3.utils/clear-nuxt-data.md +2 -2
  90. package/3.api/3.utils/clear-nuxt-state.md +2 -2
  91. package/3.api/3.utils/create-error.md +1 -1
  92. package/3.api/3.utils/define-lazy-hydration-component.md +13 -13
  93. package/3.api/3.utils/define-nuxt-component.md +5 -5
  94. package/3.api/3.utils/define-nuxt-plugin.md +11 -11
  95. package/3.api/3.utils/define-nuxt-route-middleware.md +2 -2
  96. package/3.api/3.utils/define-page-meta.md +14 -14
  97. package/3.api/3.utils/define-route-rules.md +3 -3
  98. package/3.api/3.utils/navigate-to.md +9 -9
  99. package/3.api/3.utils/preload-components.md +1 -1
  100. package/3.api/3.utils/prerender-routes.md +2 -2
  101. package/3.api/3.utils/refresh-cookie.md +3 -3
  102. package/3.api/3.utils/refresh-nuxt-data.md +9 -4
  103. package/3.api/3.utils/reload-nuxt-app.md +2 -2
  104. package/3.api/3.utils/set-response-status.md +1 -1
  105. package/3.api/3.utils/show-error.md +2 -2
  106. package/3.api/3.utils/update-app-config.md +2 -1
  107. package/3.api/4.commands/prepare.md +4 -0
  108. package/3.api/5.kit/1.modules.md +36 -36
  109. package/3.api/5.kit/10.templates.md +8 -6
  110. package/3.api/5.kit/11.nitro.md +62 -62
  111. package/3.api/5.kit/12.resolving.md +2 -2
  112. package/3.api/5.kit/14.builder.md +1 -0
  113. package/3.api/5.kit/15.examples.md +2 -2
  114. package/3.api/5.kit/16.layers.md +26 -26
  115. package/3.api/5.kit/3.compatibility.md +12 -12
  116. package/3.api/5.kit/4.autoimports.md +12 -12
  117. package/3.api/5.kit/5.components.md +5 -5
  118. package/3.api/5.kit/6.context.md +3 -3
  119. package/3.api/5.kit/7.pages.md +4 -4
  120. package/3.api/5.kit/8.layout.md +1 -1
  121. package/3.api/5.kit/9.plugins.md +5 -4
  122. package/3.api/6.advanced/2.import-meta.md +3 -3
  123. package/3.api/6.nuxt-config.md +293 -858
  124. package/6.bridge/1.overview.md +1 -1
  125. package/6.bridge/10.configuration.md +2 -1
  126. package/6.bridge/2.typescript.md +2 -2
  127. package/6.bridge/3.bridge-composition-api.md +2 -2
  128. package/6.bridge/4.plugins-and-middleware.md +5 -5
  129. package/6.bridge/5.nuxt3-compatible-api.md +11 -8
  130. package/6.bridge/6.meta.md +15 -14
  131. package/6.bridge/8.nitro.md +2 -2
  132. package/6.bridge/9.vite.md +3 -3
  133. package/7.migration/2.configuration.md +17 -15
  134. package/7.migration/4.meta.md +17 -14
  135. package/7.migration/5.plugins-and-middleware.md +5 -5
  136. package/7.migration/6.pages-and-layouts.md +15 -11
  137. package/7.migration/7.component-options.md +3 -3
  138. package/7.migration/8.runtime-config.md +3 -3
  139. package/package.json +1 -1
@@ -33,35 +33,35 @@ Additionally, certain other files in the layer directory will be auto-scanned an
33
33
  ```ts [nuxt.config.ts]
34
34
  export default defineNuxtConfig({
35
35
  extends: [
36
- './base'
37
- ]
36
+ './base',
37
+ ],
38
38
  })
39
39
  ```
40
40
 
41
41
  ```vue [app/app.vue]
42
- <template>
43
- <BaseComponent/>
44
- </template>
42
+ <template>
43
+ <BaseComponent />
44
+ </template>
45
45
  ```
46
46
 
47
47
  ```ts [base/nuxt.config.ts]
48
- export default defineNuxtConfig({
49
- // Extending from base nuxt.config.ts!
50
- app: {
51
- head: {
52
- title: 'Extending Configs is Fun!',
53
- meta: [
54
- { name: 'description', content: 'I am using the extends feature in Nuxt!' }
55
- ],
56
- }
57
- }
58
- })
48
+ export default defineNuxtConfig({
49
+ // Extending from base nuxt.config.ts!
50
+ app: {
51
+ head: {
52
+ title: 'Extending Configs is Fun!',
53
+ meta: [
54
+ { name: 'description', content: 'I am using the extends feature in Nuxt!' },
55
+ ],
56
+ },
57
+ },
58
+ })
59
59
  ```
60
60
 
61
61
  ```vue [base/app/components/BaseComponent.vue]
62
- <template>
63
- <h1>Extending Components is Fun!</h1>
64
- </template>
62
+ <template>
63
+ <h1>Extending Components is Fun!</h1>
64
+ </template>
65
65
  ```
66
66
 
67
67
  ::
@@ -79,10 +79,13 @@ For example:
79
79
  ```ts [nuxt.config.ts]
80
80
  export default defineNuxtConfig({
81
81
  extends: [
82
- './layers/base', // Highest priority (among extends)
83
- './layers/theme', // Medium priority
84
- './layers/custom' // Lower priority
85
- ]
82
+ // Highest priority (among extends)
83
+ './layers/base',
84
+ // Medium priority
85
+ './layers/theme',
86
+ // Lower priority
87
+ './layers/custom',
88
+ ],
86
89
  // Your project has the highest priority
87
90
  })
88
91
  ```
@@ -110,13 +113,19 @@ You can use a git repository to share your Nuxt layer. Some examples:
110
113
  ```ts [nuxt.config.ts]
111
114
  export default defineNuxtConfig({
112
115
  extends: [
113
- 'github:username/repoName', // GitHub Remote Source
114
- 'github:username/repoName/base', // GitHub Remote Source within /base directory
115
- 'github:username/repoName#dev', // GitHub Remote Source from dev branch
116
- 'github:username/repoName#v1.0.0', // GitHub Remote Source from v1.0.0 tag
117
- 'gitlab:username/repoName', // GitLab Remote Source example
118
- 'bitbucket:username/repoName', // Bitbucket Remote Source example
119
- ]
116
+ // GitHub Remote Source
117
+ 'github:username/repoName',
118
+ // GitHub Remote Source within /base directory
119
+ 'github:username/repoName/base',
120
+ // GitHub Remote Source from dev branch
121
+ 'github:username/repoName#dev',
122
+ // GitHub Remote Source from v1.0.0 tag
123
+ 'github:username/repoName#v1.0.0',
124
+ // GitLab Remote Source example
125
+ 'gitlab:username/repoName',
126
+ // Bitbucket Remote Source example
127
+ 'bitbucket:username/repoName',
128
+ ],
120
129
  })
121
130
  ```
122
131
 
@@ -138,8 +147,8 @@ When using git remote sources, if a layer has npm dependencies and you wish to i
138
147
  ```ts [nuxt.config.ts]
139
148
  export default defineNuxtConfig({
140
149
  extends: [
141
- ['github:username/repoName', { install: true }]
142
- ]
150
+ ['github:username/repoName', { install: true }],
151
+ ],
143
152
  })
144
153
  ```
145
154
  ::
@@ -156,8 +165,8 @@ export default defineNuxtConfig({
156
165
  // Node Module with scope
157
166
  '@scope/moduleName',
158
167
  // or just the module name
159
- 'moduleName'
160
- ]
168
+ 'moduleName',
169
+ ],
161
170
  })
162
171
  ```
163
172
 
@@ -210,16 +219,16 @@ When importing using global aliases (such as `~/` and `@/`) in a layer component
210
219
 
211
220
  Also when using relative paths in `nuxt.config` file of a layer, (with exception of nested `extends`) they are resolved relative to user's project instead of the layer. As a workaround, use full resolved paths in `nuxt.config`:
212
221
 
213
- ```js [nuxt.config.ts]
214
- import { fileURLToPath } from 'url'
215
- import { dirname, join } from 'path'
222
+ ```ts [nuxt.config.ts]
223
+ import { fileURLToPath } from 'node:url'
224
+ import { dirname, join } from 'node:path'
216
225
 
217
226
  const currentDir = dirname(fileURLToPath(import.meta.url))
218
227
 
219
228
  export default defineNuxtConfig({
220
229
  css: [
221
- join(currentDir, './app/assets/main.css')
222
- ]
230
+ join(currentDir, './app/assets/main.css'),
231
+ ],
223
232
  })
224
233
  ```
225
234
 
@@ -229,12 +238,12 @@ You can use the internal array `nuxt.options._layers` to support custom multi-la
229
238
 
230
239
  ```ts [modules/my-module.ts]
231
240
  export default defineNuxtModule({
232
- setup(_options, nuxt) {
241
+ setup (_options, nuxt) {
233
242
  for (const layer of nuxt.options._layers) {
234
243
  // You can check for a custom directory existence to extend for each layer
235
244
  console.log('Custom extension for', layer.cwd, layer.config)
236
245
  }
237
- }
246
+ },
238
247
  })
239
248
  ```
240
249
 
@@ -12,8 +12,8 @@ export default defineNuxtConfig({
12
12
  // or sourcemap: true
13
13
  sourcemap: {
14
14
  server: true,
15
- client: true
16
- }
15
+ client: true,
16
+ },
17
17
  })
18
18
  ```
19
19
 
@@ -18,12 +18,12 @@ import type { RouterConfig } from '@nuxt/schema'
18
18
 
19
19
  export default {
20
20
  // https://router.vuejs.org/api/interfaces/routeroptions.html#routes
21
- routes: (_routes) => [
21
+ routes: _routes => [
22
22
  {
23
23
  name: 'home',
24
24
  path: '/',
25
- component: () => import('~/pages/home.vue')
26
- }
25
+ component: () => import('~/pages/home.vue'),
26
+ },
27
27
  ],
28
28
  } satisfies RouterConfig
29
29
  ```
@@ -48,7 +48,7 @@ export default defineNuxtConfig({
48
48
  pages.push({
49
49
  name: 'profile',
50
50
  path: '/profile',
51
- file: '~/extra-pages/profile.vue'
51
+ file: '~/extra-pages/profile.vue',
52
52
  })
53
53
 
54
54
  // remove routes
@@ -66,8 +66,8 @@ export default defineNuxtConfig({
66
66
  }
67
67
  }
68
68
  removePagesMatching(/\.ts$/, pages)
69
- }
70
- }
69
+ },
70
+ },
71
71
  })
72
72
  ```
73
73
 
@@ -110,10 +110,10 @@ export default defineNuxtConfig({
110
110
  // add a route
111
111
  files.push({
112
112
  path: resolver.resolve('./runtime/router-options'),
113
- optional: true
113
+ optional: true,
114
114
  })
115
- }
116
- }
115
+ },
116
+ },
117
117
  })
118
118
  ```
119
119
 
@@ -129,11 +129,11 @@ export default defineNuxtConfig({
129
129
  - `hashMode`
130
130
  - `scrollBehaviorType`
131
131
 
132
- ```js [nuxt.config]
132
+ ```ts [nuxt.config]
133
133
  export default defineNuxtConfig({
134
134
  router: {
135
- options: {}
136
- }
135
+ options: {},
136
+ },
137
137
  })
138
138
  ```
139
139
 
@@ -146,9 +146,9 @@ export default defineNuxtConfig({
146
146
  ssr: false,
147
147
  router: {
148
148
  options: {
149
- hashMode: true
150
- }
151
- }
149
+ hashMode: true,
150
+ },
151
+ },
152
152
  })
153
153
  ```
154
154
 
@@ -160,9 +160,9 @@ You can optionally customize the scroll behavior for hash links. When you set th
160
160
  export default defineNuxtConfig({
161
161
  router: {
162
162
  options: {
163
- scrollBehaviorType: 'smooth'
164
- }
165
- }
163
+ scrollBehaviorType: 'smooth',
164
+ },
165
+ },
166
166
  })
167
167
  ```
168
168
 
@@ -176,6 +176,6 @@ import { createMemoryHistory } from 'vue-router'
176
176
 
177
177
  export default {
178
178
  // https://router.vuejs.org/api/interfaces/routeroptions.html
179
- history: base => import.meta.client ? createMemoryHistory(base) : null /* default */
179
+ history: base => import.meta.client ? createMemoryHistory(base) : null, /* default */
180
180
  } satisfies RouterConfig
181
181
  ```
@@ -36,9 +36,9 @@ import yaml from '@rollup/plugin-yaml'
36
36
  export default defineNuxtConfig({
37
37
  vite: {
38
38
  plugins: [
39
- yaml()
40
- ]
41
- }
39
+ yaml(),
40
+ ],
41
+ },
42
42
  })
43
43
  ```
44
44
 
@@ -29,24 +29,24 @@ export default defineNuxtPlugin((nuxtApp) => {
29
29
 
30
30
  const api = $fetch.create({
31
31
  baseURL: 'https://api.nuxt.com',
32
- onRequest({ request, options, error }) {
32
+ onRequest ({ request, options, error }) {
33
33
  if (session.value?.token) {
34
34
  // note that this relies on ofetch >= 1.4.0 - you may need to refresh your lockfile
35
35
  options.headers.set('Authorization', `Bearer ${session.value?.token}`)
36
36
  }
37
37
  },
38
- async onResponseError({ response }) {
38
+ async onResponseError ({ response }) {
39
39
  if (response.status === 401) {
40
40
  await nuxtApp.runWithContext(() => navigateTo('/login'))
41
41
  }
42
- }
42
+ },
43
43
  })
44
44
 
45
45
  // Expose to useNuxtApp().$api
46
46
  return {
47
47
  provide: {
48
- api
49
- }
48
+ api,
49
+ },
50
50
  }
51
51
  })
52
52
  ```
@@ -71,13 +71,13 @@ Now that `$api` has the logic we want, let's create a `useAPI` composable to rep
71
71
  ```ts [app/composables/useAPI.ts]
72
72
  import type { UseFetchOptions } from 'nuxt/app'
73
73
 
74
- export function useAPI<T>(
74
+ export function useAPI<T> (
75
75
  url: string | (() => string),
76
76
  options?: UseFetchOptions<T>,
77
77
  ) {
78
78
  return useFetch(url, {
79
79
  ...options,
80
- $fetch: useNuxtApp().$api as typeof $fetch
80
+ $fetch: useNuxtApp().$api as typeof $fetch,
81
81
  })
82
82
  }
83
83
  ```
@@ -101,13 +101,13 @@ interface CustomError {
101
101
  statusCode: number
102
102
  }
103
103
 
104
- export function useAPI<T>(
104
+ export function useAPI<T> (
105
105
  url: string | (() => string),
106
106
  options?: UseFetchOptions<T>,
107
107
  ) {
108
108
  return useFetch<T, FetchError<CustomError>>(url, {
109
109
  ...options,
110
- $fetch: useNuxtApp().$api
110
+ $fetch: useNuxtApp().$api,
111
111
  })
112
112
  }
113
113
  ```
@@ -48,7 +48,7 @@ import { z } from 'zod'
48
48
 
49
49
  const bodySchema = z.object({
50
50
  email: z.string().email(),
51
- password: z.string().min(8)
51
+ password: z.string().min(8),
52
52
  })
53
53
 
54
54
  export default defineEventHandler(async (event) => {
@@ -59,14 +59,14 @@ export default defineEventHandler(async (event) => {
59
59
  // this server util is auto-imported by the auth-utils module
60
60
  await setUserSession(event, {
61
61
  user: {
62
- name: 'John Doe'
63
- }
62
+ name: 'John Doe',
63
+ },
64
64
  })
65
65
  return {}
66
66
  }
67
67
  throw createError({
68
68
  statusCode: 401,
69
- message: 'Bad credentials'
69
+ message: 'Bad credentials',
70
70
  })
71
71
  })
72
72
  ```
@@ -98,25 +98,37 @@ const credentials = reactive({
98
98
  email: '',
99
99
  password: '',
100
100
  })
101
- async function login() {
102
- $fetch('/api/login', {
103
- method: 'POST',
104
- body: credentials
105
- })
106
- .then(async () => {
101
+ async function login () {
102
+ try {
103
+ await $fetch('/api/login', {
104
+ method: 'POST',
105
+ body: credentials,
106
+ })
107
+
107
108
  // Refresh the session on client-side and redirect to the home page
108
109
  await refreshSession()
109
110
  await navigateTo('/')
110
- })
111
- .catch(() => alert('Bad credentials'))
111
+ } catch {
112
+ alert('Bad credentials')
113
+ }
112
114
  }
113
115
  </script>
114
116
 
115
117
  <template>
116
118
  <form @submit.prevent="login">
117
- <input v-model="credentials.email" type="email" placeholder="Email" />
118
- <input v-model="credentials.password" type="password" placeholder="Password" />
119
- <button type="submit">Login</button>
119
+ <input
120
+ v-model="credentials.email"
121
+ type="email"
122
+ placeholder="Email"
123
+ >
124
+ <input
125
+ v-model="credentials.password"
126
+ type="password"
127
+ placeholder="Password"
128
+ >
129
+ <button type="submit">
130
+ Login
131
+ </button>
120
132
  </form>
121
133
  </template>
122
134
  ```
@@ -138,7 +150,7 @@ export default defineEventHandler(async (event) => {
138
150
  // TODO: Fetch some stats based on the user
139
151
 
140
152
  return {}
141
- });
153
+ })
142
154
  ```
143
155
 
144
156
  ## Protect App Routes
@@ -171,10 +183,10 @@ We'll use [`definePageMeta`](/docs/4.x/api/utils/define-page-meta) to apply the
171
183
  definePageMeta({
172
184
  middleware: ['authenticated'],
173
185
  })
174
-
186
+
175
187
  const { user, clear: clearSession } = useUserSession()
176
188
 
177
- async function logout() {
189
+ async function logout () {
178
190
  await clearSession()
179
191
  await navigateTo('/login')
180
192
  }
@@ -183,7 +195,9 @@ async function logout() {
183
195
  <template>
184
196
  <div>
185
197
  <h1>Welcome {{ user.name }}</h1>
186
- <button @click="logout">Logout</button>
198
+ <button @click="logout">
199
+ Logout
200
+ </button>
187
201
  </div>
188
202
  </template>
189
203
  ```
@@ -34,8 +34,8 @@ export default defineNuxtConfig({
34
34
  nuxtLink: {
35
35
  prefetchOn: 'interaction',
36
36
  },
37
- }
38
- }
37
+ },
38
+ },
39
39
  })
40
40
  ```
41
41
 
@@ -51,18 +51,18 @@ Hybrid rendering allows different caching rules per route using Route Rules and
51
51
  export default defineNuxtConfig({
52
52
  routeRules: {
53
53
  '/': {
54
- prerender: true
54
+ prerender: true,
55
55
  },
56
56
  '/products/**': {
57
- swr: 3600
57
+ swr: 3600,
58
58
  },
59
59
  '/blog': {
60
- isr: 3600
60
+ isr: 3600,
61
61
  },
62
62
  '/admin/**': {
63
- ssr: false
63
+ ssr: false,
64
64
  },
65
- }
65
+ },
66
66
  })
67
67
  ```
68
68
 
@@ -193,7 +193,7 @@ Nuxt Scripts provides an abstraction layer on top of third-party scripts, provid
193
193
 
194
194
  ```ts
195
195
  const { onLoaded, proxy } = useScriptGoogleAnalytics(
196
- {
196
+ {
197
197
  id: 'G-1234567',
198
198
  scriptOptions: {
199
199
  trigger: 'manual',
@@ -24,7 +24,10 @@ The content of the default slot will be tree-shaken out of the server build. (Th
24
24
  <div>
25
25
  <Sidebar />
26
26
  <!-- The <Comment> component will only be rendered on client-side -->
27
- <ClientOnly fallback-tag="span" fallback="Loading comments...">
27
+ <ClientOnly
28
+ fallback-tag="span"
29
+ fallback="Loading comments..."
30
+ >
28
31
  <Comment />
29
32
  </ClientOnly>
30
33
  </div>
@@ -40,7 +43,7 @@ The content of the default slot will be tree-shaken out of the server build. (Th
40
43
  <div>
41
44
  <Sidebar />
42
45
  <!-- This renders the "span" element on the server side -->
43
- <ClientOnly fallbackTag="span">
46
+ <ClientOnly fallback-tag="span">
44
47
  <!-- this component will only be rendered on client side -->
45
48
  <Comments />
46
49
  <template #fallback>
@@ -64,7 +67,7 @@ const nuxtWelcomeRef = useTemplateRef('nuxtWelcomeRef')
64
67
 
65
68
  // The watch will be triggered when the component is available
66
69
  watch(nuxtWelcomeRef, () => {
67
- console.log('<NuxtWelcome /> mounted')
70
+ console.log('<NuxtWelcome /> mounted')
68
71
  }, { once: true })
69
72
  </script>
70
73
 
@@ -55,12 +55,15 @@ This component is experimental and in order to use it you must enable the `exper
55
55
  - **default**: `false`
56
56
 
57
57
  ```vue
58
- <template>
59
- <!-- render <span>Hello world</span> server-side if the default slot fails to render -->
60
- <NuxtClientFallback fallback-tag="span" fallback="Hello world">
61
- <BrokeInSsr />
62
- </NuxtClientFallback>
63
- </template>
58
+ <template>
59
+ <!-- render <span>Hello world</span> server-side if the default slot fails to render -->
60
+ <NuxtClientFallback
61
+ fallback-tag="span"
62
+ fallback="Hello world"
63
+ >
64
+ <BrokeInSSR />
65
+ </NuxtClientFallback>
66
+ </template>
64
67
  ```
65
68
 
66
69
  ## Slots
@@ -15,7 +15,10 @@ The `to` target of [`<Teleport>`](https://vuejs.org/guide/built-ins/teleport.htm
15
15
  Open Modal
16
16
  </button>
17
17
  <Teleport to="#teleports">
18
- <div v-if="open" class="modal">
18
+ <div
19
+ v-if="open"
20
+ class="modal"
21
+ >
19
22
  <p>Hello from the modal!</p>
20
23
  <button @click="open = false">
21
24
  Close
@@ -32,13 +32,13 @@ Add `<NuxtRouteAnnouncer/>` in your [`app.vue`](/docs/4.x/guide/directory-struct
32
32
  You can pass custom HTML or components through the route announcer's default slot.
33
33
 
34
34
  ```vue
35
- <template>
36
- <NuxtRouteAnnouncer>
37
- <template #default="{ message }">
38
- <p>{{ message }} was loaded.</p>
39
- </template>
40
- </NuxtRouteAnnouncer>
41
- </template>
35
+ <template>
36
+ <NuxtRouteAnnouncer>
37
+ <template #default="{ message }">
38
+ <p>{{ message }} was loaded.</p>
39
+ </template>
40
+ </NuxtRouteAnnouncer>
41
+ </template>
42
42
  ```
43
43
 
44
44
  ## Props