@nuxt/docs-nightly 4.4.3-29561554.e9b2fa64 → 4.4.3-29571486.e4b31efa

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.
@@ -62,6 +62,7 @@ When you set your `future.compatibilityVersion` to `5`, defaults throughout your
62
62
  - **Normalized Page Names**: Page component names will [match their route names](/docs/4.x/getting-started/upgrade#normalized-page-component-names) for consistent `<KeepAlive>` behavior
63
63
  - **`clearNuxtState` resets to defaults**: `clearNuxtState` will [reset state to its initial value](/docs/4.x/getting-started/upgrade#respect-defaults-when-clearing-usestate) instead of setting it to `undefined`
64
64
  - **Non-async `callHook`**: [`callHook` may return `void`](/docs/4.x/getting-started/upgrade#non-async-callhook) instead of always returning a `Promise`
65
+ - **Comment node placeholders**: Client-only components use [comment nodes instead of `<div>`](/docs/4.x/getting-started/upgrade#client-only-comment-placeholders) as SSR placeholders, fixing a scoped styles hydration issue
65
66
  - Other Nuxt 5 improvements and changes as they become available
66
67
 
67
68
  ::note
@@ -227,6 +228,46 @@ export default defineNuxtConfig({
227
228
  })
228
229
  ```
229
230
 
231
+ ### Client-Only Comment Placeholders
232
+
233
+ 🚦 **Impact Level**: Minimal
234
+
235
+ #### What Changed
236
+
237
+ With `compatibilityVersion: 5`, client-only components (`.client.vue` files and `createClientOnly()` wrappers) now render an HTML comment (`<!--placeholder-->`) on the server instead of an empty `<div>` element.
238
+
239
+ #### Reasons for Change
240
+
241
+ When the placeholder `<div>` and the actual component root share the same tag name, Vue's runtime skips re-applying `setScopeId` during hydration. This causes scoped styles to be missing after the component mounts. Using a comment node avoids the tag name collision entirely.
242
+
243
+ #### Migration Steps
244
+
245
+ If you rely on the placeholder `<div>` to inherit attributes (`class`, `style`, etc.) for layout purposes (e.g., reserving space to prevent layout shift), wrap the component in `<ClientOnly>` with a `#fallback` slot instead:
246
+
247
+ ```diff
248
+ - <MyComponent class="placeholder" style="min-height: 200px" />
249
+ + <ClientOnly>
250
+ + <MyComponent />
251
+ + <template #fallback>
252
+ + <div class="placeholder" style="min-height: 200px"></div>
253
+ + </template>
254
+ + </ClientOnly>
255
+ ```
256
+
257
+ ::tip
258
+ You can test this feature early by setting `future.compatibilityVersion: 5` (see [Testing Nuxt 5](/docs/4.x/getting-started/upgrade#testing-nuxt-5)) or by enabling it explicitly with `experimental.clientNodePlaceholder: true`.
259
+ ::
260
+
261
+ Alternatively, you can revert to the previous `<div>` placeholder behavior with:
262
+
263
+ ```ts twoslash [nuxt.config.ts]
264
+ export default defineNuxtConfig({
265
+ experimental: {
266
+ clientNodePlaceholder: false,
267
+ },
268
+ })
269
+ ```
270
+
230
271
  ## Migrating to Nuxt 4
231
272
 
232
273
  Nuxt 4 includes significant improvements and changes. This guide will help you migrate your existing Nuxt 3 application to Nuxt 4.
@@ -168,7 +168,7 @@ This is useful when you want to manage layouts centrally in your configuration r
168
168
 
169
169
  :link-example{to="/docs/4.x/examples/features/layouts"}
170
170
 
171
- ## Passing Props to Layouts
171
+ ## Passing Props to Layouts :badge[+4.4]{color="primary" class="align-middle"}
172
172
 
173
173
  You can pass props to layouts in several ways.
174
174
 
@@ -270,6 +270,26 @@ export default defineNuxtConfig({
270
270
  })
271
271
  ```
272
272
 
273
+ ## clientNodePlaceholder
274
+
275
+ Uses comment nodes (`<!--placeholder-->`) instead of `<div>` elements as placeholders for client-only components during server-side rendering.
276
+
277
+ When enabled, `.client.vue` components and `createClientOnly()` wrappers render an HTML comment on the server instead of an empty `<div>`. This fixes a Vue hydration issue where scoped styles may not be applied when the placeholder `<div>` and the actual component root share the same tag name.
278
+
279
+ ::warning
280
+ Enabling this means attributes (`class`, `style`, etc.) passed to `.client.vue` components will not appear in the SSR HTML. If you need styled placeholders to prevent layout shift, use `<ClientOnly>` with a `#fallback` slot instead.
281
+ ::
282
+
283
+ This flag is enabled when `future.compatibilityVersion` is set to `5` or higher, but you can also enable it explicitly:
284
+
285
+ ```ts twoslash [nuxt.config.ts]
286
+ export default defineNuxtConfig({
287
+ experimental: {
288
+ clientNodePlaceholder: true,
289
+ },
290
+ })
291
+ ```
292
+
273
293
  ## clientFallback
274
294
 
275
295
  Enables the experimental [`<NuxtClientFallback>`](/docs/4.x/api/components/nuxt-client-fallback) component for rendering content on the client if there's an error in SSR.
@@ -378,7 +398,7 @@ export default defineNuxtConfig({
378
398
 
379
399
  ## typedPages
380
400
 
381
- Enable the new experimental typed router using [`unplugin-vue-router`](https://github.com/posva/unplugin-vue-router).
401
+ Enable the new experimental typed router.
382
402
 
383
403
  ```ts twoslash [nuxt.config.ts]
384
404
  export default defineNuxtConfig({
@@ -392,14 +412,6 @@ Out of the box, this will enable typed usage of [`navigateTo`](/docs/4.x/api/uti
392
412
 
393
413
  You can even get typed params within a page by using `const route = useRoute('route-name')`.
394
414
 
395
- ::important
396
- If you use `pnpm` without `shamefully-hoist=true`, you will need to add `unplugin-vue-router` as a hoist pattern in your `pnpm-workspace.yaml` in order for this feature to work.
397
- ```yaml
398
- publicHoistPattern:
399
- - "unplugin-vue-router"
400
- ```
401
- ::
402
-
403
415
  :video-accordion{title="Watch a video from Daniel Roe explaining type-safe routing in Nuxt" videoId="SXk-L19gTZk"}
404
416
 
405
417
  ## watcher
@@ -48,6 +48,10 @@ This is similar to using `v-html` with external content - the remote server can
48
48
  The `dangerouslyLoadClientComponents` prop controls an additional layer of risk: whether to also download and execute client components from the remote source. Even with `dangerouslyLoadClientComponents` disabled (the default), you are still trusting the remote server's HTML output.
49
49
  ::
50
50
 
51
+ ::note
52
+ Component props and context are sent as GET query parameters to enable caching. Query parameters may be visible in server access logs, CDN caches, and HTTP `Referer` headers.
53
+ ::
54
+
51
55
  ::note
52
56
  By default, component islands are scanned from the `~/components/islands/` directory. So the `~/components/islands/MyIsland.vue` component could be rendered with `<NuxtIsland name="MyIsland" />`.
53
57
  ::
@@ -87,11 +87,16 @@ This is useful for enforcing settings like authentication headers or a specific
87
87
  You can pass a custom `$fetch` instance to `createUseFetch`:
88
88
 
89
89
  ```ts [app/composables/useAPI.ts]
90
- export const useAPI = createUseFetch({
90
+ export const useAPI = createUseFetch(callerOptions => ({
91
91
  $fetch: useNuxtApp().$api as typeof $fetch,
92
- })
92
+ ...callerOptions,
93
+ }))
93
94
  ```
94
95
 
96
+ ::important
97
+ The **function signature** (override mode) is required here so that [`useNuxtApp()`](/docs/4.x/api/composables/use-nuxt-app) is called in the setup context (at the composable call site) rather than in the module scope, where no Nuxt instance is available.
98
+ ::
99
+
95
100
  :read-more{to="/docs/4.x/guide/recipes/custom-usefetch"}
96
101
 
97
102
  :read-more{to="/docs/4.x/api/composables/use-fetch"}
@@ -139,6 +139,7 @@ type UseFetchOptions<DataT> = {
139
139
  body?: MaybeRefOrGetter<RequestInit['body'] | Record<string, any>>
140
140
  headers?: MaybeRefOrGetter<Record<string, string> | [key: string, value: string][] | Headers>
141
141
  baseURL?: MaybeRefOrGetter<string>
142
+ cache?: false | 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload'
142
143
  server?: boolean
143
144
  lazy?: boolean
144
145
  immediate?: boolean
@@ -192,7 +193,7 @@ type AsyncDataRequestStatus = 'idle' | 'pending' | 'success' | 'error'
192
193
  | `body` | `MaybeRefOrGetter<RequestInit['body'] \| Record<string, any>>` | - | Request body. Objects are automatically stringified. |
193
194
  | `headers` | `MaybeRefOrGetter<Record<string, string> \| [key, value][] \| Headers>` | - | Request headers. |
194
195
  | `baseURL` | `MaybeRefOrGetter<string>` | - | Base URL for the request. |
195
- | `cache` | `boolean \| string` | - | Cache control. Boolean disables cache, or use Fetch API values: `default`, `no-store`, etc. |
196
+ | `cache` | `false \| string` | - | Cache control. Boolean disables cache, or use Fetch API values: `default`, `no-store`, etc. |
196
197
  | `server` | `boolean` | `true` | Whether to fetch on the server. |
197
198
  | `lazy` | `boolean` | `false` | If true, resolves after route loads (does not block navigation). |
198
199
  | `immediate` | `boolean` | `true` | If false, prevents request from firing immediately. |
@@ -118,16 +118,19 @@ import { addImportsSources, defineNuxtModule } from '@nuxt/kit'
118
118
 
119
119
  export default defineNuxtModule({
120
120
  setup () {
121
- addImportsSources({
122
- from: 'h3',
123
- imports: [
124
- 'defineEventHandler',
125
- 'getQuery',
126
- 'getRouterParams',
127
- 'readBody',
128
- 'sendRedirect',
129
- ],
130
- })
121
+ addImportsSources([
122
+ { package: '@vueuse/core' },
123
+ {
124
+ from: 'h3',
125
+ imports: [
126
+ 'defineEventHandler',
127
+ 'getQuery',
128
+ 'getRouterParams',
129
+ 'readBody',
130
+ 'sendRedirect',
131
+ ],
132
+ },
133
+ ])
131
134
  },
132
135
  })
133
136
  ```
@@ -135,14 +138,22 @@ export default defineNuxtModule({
135
138
  ### Type
136
139
 
137
140
  ```ts
138
- function addImportsSources (importSources: ImportSource | ImportSource[]): void
141
+ function addImportsSources (importSources: Preset | Preset[]): void
139
142
  ```
140
143
 
141
144
  ### Parameters
142
145
 
143
146
  **importSources**: An object or an array of objects with the following properties:
144
147
 
148
+ - InlinePreset
149
+
145
150
  | Property | Type | Required | Description |
146
151
  |-----------|---------------------------------------------|----------|------------------------------------------------------------------------------------------------|
147
152
  | `from` | `string` | `true` | Module specifier to import from. |
148
153
  | `imports` | `PresetImport \| ImportSource[]`{lang="ts"} | `true` | An object or an array of objects, which can be import names, import objects or import sources. |
154
+
155
+ - PackagePreset
156
+
157
+ | Property | Type | Required | Description |
158
+ |-----------|---------------------------------------------|----------|------------------------------------------------------------------------------------------------|
159
+ | `package` | `string` | `true` | Name of the package. |
@@ -26,7 +26,7 @@ Check the [app source code](https://github.com/nuxt/nuxt/blob/main/packages/nuxt
26
26
  | `link:prefetch` | `to` | Client | Called when a `<NuxtLink>` is observed to be prefetched. |
27
27
  | `page:start` | `pageComponent?` | Client | Called on [Suspense](https://vuejs.org/guide/built-ins/suspense#suspense) inside of `NuxtPage` pending event. |
28
28
  | `page:finish` | `pageComponent?` | Client | Called on [Suspense](https://vuejs.org/guide/built-ins/suspense#suspense) inside of `NuxtPage` resolved event. |
29
- | `page:loading:start` | - | Client | Called when the `setup()` of the new page is running. |
29
+ | `page:loading:start` | - | Client | Called when a route navigation begins (before resolution) or when the page key changes. May fire without the page component's `setup()` re-running if the page is reused (e.g. with a static `key` in `definePageMeta`). |
30
30
  | `page:loading:end` | - | Client | Called after `page:finish` |
31
31
  | `page:transition:finish` | `pageComponent?` | Client | After page transition [onAfterLeave](https://vuejs.org/guide/built-ins/transition#javascript-hooks) event. |
32
32
  | `dev:ssr-logs` | `logs` | Client | Called with an array of server-side logs that have been passed to the client (if `features.devLogs` is enabled). |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/docs-nightly",
3
- "version": "4.4.3-29561554.e9b2fa64",
3
+ "version": "4.4.3-29571486.e4b31efa",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",