@nuxt/docs-nightly 5.0.0-2610271652-3b4f925 → 5.0.0-2610272000-c73c4e1

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.
@@ -91,7 +91,7 @@ Because props come from the request (URL query or body), treat them as untrusted
91
91
 
92
92
  Treating props as untrusted includes their size: validate or clamp numeric and array props before using them to drive a `v-for` or other work that grows with their value. Nuxt caps numeric `v-for` sources at 10,000 iterations in island renders, but only as a safety net, not as validation.
93
93
 
94
- Props a component does not declare fall through as attributes onto its single root element, so an island whose root is a polymorphic component (e.g. from `reka-ui` / `@nuxt/ui`) can receive attributes you did not bind. Set `defineOptions({ inheritAttrs: false })`{lang=ts} on such islands, or declare the props you accept.
94
+ Props a component does not declare fall through as attributes onto its single root element, so an island whose root is a polymorphic component (e.g. from `reka-ui` / `@nuxt/ui`) can receive attributes you did not bind. Set `defineOptions({ inheritAttrs: false })`{lang=ts} on such islands, or declare the props you accept. As with any Vue component, fall-through attributes include event handler attributes such as `onclick` or `onfocus`, which the browser runs as JavaScript, so don't spread an object you don't control (such as `route.query`) onto a server component or into the `props` of `<NuxtIsland>`{lang=vue}.
95
95
 
96
96
  To switch components based on caller input, map a discriminator through an allowlist of imported components rather than passing the raw prop:
97
97
 
@@ -287,6 +287,30 @@ This is opt-in because it can break apps that rely on runtime routing:
287
287
  The option is disabled automatically in development, when `hashMode` is enabled, when a root-level catch-all page (such as `pages/[...slug].vue`) matches every path, and when a custom `app/router.options` file may modify `routes` (a file whose default export is a plain object without a `routes` key remains compatible).
288
288
  ::
289
289
 
290
+ ## templateDiagnostics
291
+
292
+ Warns at build time about template mistakes the Vue compiler cannot detect, because they depend on what Nuxt knows about your app:
293
+
294
+ - [`NUXT_B4025`](/docs/errors/b4025): a `<NuxtLink>` whose static `to` matches no page route
295
+ - [`NUXT_B3014`](/docs/errors/b3014): `v-on` or `v-model` on a server component
296
+ - [`NUXT_B3015`](/docs/errors/b3015): a function or class instance passed as a prop to a server component, or in the `props` of a `<NuxtIsland>`
297
+
298
+ Warnings are printed to the terminal with the template location and, in development, sent to open error pages and overlays.
299
+
300
+ This flag is enabled by default, but you can disable this feature:
301
+
302
+ ```ts twoslash [nuxt.config.ts]
303
+ export default defineNuxtConfig({
304
+ experimental: {
305
+ templateDiagnostics: false,
306
+ },
307
+ })
308
+ ```
309
+
310
+ ::warning
311
+ The route check cannot see routes added at runtime with `router.addRoute()` or paths that route middleware redirects, and is skipped when a custom `app/router.options` file may modify `routes`.
312
+ ::
313
+
290
314
  ## clientFallback
291
315
 
292
316
  Enables the experimental [`<NuxtClientFallback>`](/docs/api/components/nuxt-client-fallback) component for rendering content on the client if there's an error in SSR.
@@ -24,3 +24,58 @@ export default defineNuxtPlugin(() => {
24
24
  ```
25
25
 
26
26
  It is 'safe' to run even after your app has initialized. In this case, then the code will be registered to run in the next idle callback.
27
+
28
+ ## Type
29
+
30
+ ```ts [Signature]
31
+ export function onNuxtReady (callback: () => any, options?: OnNuxtReadyOptions): void
32
+
33
+ interface OnNuxtReadyOptions {
34
+ timeout?: number
35
+ signal?: AbortSignal
36
+ }
37
+ ```
38
+
39
+ ### `callback`
40
+
41
+ **Type**: `() => any`
42
+
43
+ The function to run once your app has finished initializing and the browser is idle.
44
+
45
+ ### `options` (optional)
46
+
47
+ **Type**: `OnNuxtReadyOptions`
48
+
49
+ - `timeout` (optional)
50
+
51
+ **Type**: `number`
52
+
53
+ The maximum number of milliseconds to wait for the browser to become idle once your app is ready. It is passed to [`requestIdleCallback`](https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback#timeout). Without it, the callback may be delayed for several seconds if the browser does not schedule an idle period, which can happen in headless browsers.
54
+
55
+ ```ts [app/plugins/ready.client.ts]
56
+ export default defineNuxtPlugin(() => {
57
+ onNuxtReady(() => {
58
+ // runs when the browser is idle, or about 2 seconds after your app is ready, whichever comes first
59
+ }, { timeout: 2000 })
60
+ })
61
+ ```
62
+
63
+ - `signal` (optional)
64
+
65
+ **Type**: `AbortSignal`
66
+
67
+ Skips the callback if the signal is aborted before it runs. This is useful when calling `onNuxtReady` from a component that may unmount before your app is ready.
68
+
69
+ ```vue [app/components/MyComponent.vue]
70
+ <script setup lang="ts">
71
+ const controller = new AbortController()
72
+
73
+ onMounted(() => {
74
+ onNuxtReady(() => {
75
+ // does not run if the component unmounts first
76
+ }, { signal: controller.signal })
77
+ })
78
+
79
+ onBeforeUnmount(() => controller.abort())
80
+ </script>
81
+ ```
@@ -0,0 +1,27 @@
1
+ ---
2
+ title: 'NUXT_B3014'
3
+ description: 'Event listener on a server component'
4
+ navigation: false
5
+ ---
6
+
7
+ # B3014
8
+
9
+ A template uses `v-on` (or `@`) or `v-model` on a server component. Server components render on the server only and ship no JavaScript for themselves, so they never emit events and cannot update a `v-model` binding. The listener is never called.
10
+
11
+ This warning is reported unless [`experimental.templateDiagnostics`](/docs/guide/going-further/experimental-features#templatediagnostics) is disabled. `@error` is not reported: a server component emits `error` when it fails to load.
12
+
13
+ ## Resolution
14
+
15
+ Render the interactive part on the client. You can pair the server component with a `.client.vue` component of the same name, render an interactive child with the `nuxt-client` attribute (with `experimental.componentIslands.selectiveClient` enabled), or move the listener to a client component that wraps the server component.
16
+
17
+ ```vue [app/components/Counter.server.vue]
18
+ <template>
19
+ <div>
20
+ <!-- rendered on the server, then hydrated on the client -->
21
+ <CounterButton nuxt-client />
22
+ </div>
23
+ </template>
24
+ ```
25
+
26
+ ::read-more{to="/docs/guide/concepts/server-components"}
27
+ ::
@@ -0,0 +1,27 @@
1
+ ---
2
+ title: 'NUXT_B3015'
3
+ description: 'Non-serializable prop on a server component'
4
+ navigation: false
5
+ ---
6
+
7
+ # B3015
8
+
9
+ A template passes a function, a class or a class instance (such as `new Date()`) as a prop to a server component, or in the `props` or `context` of a `<NuxtIsland>`. Props of a server component are serialized as JSON and sent to the server to render it, so these values cannot reach the component intact.
10
+
11
+ This warning is reported unless [`experimental.templateDiagnostics`](/docs/guide/going-further/experimental-features#templatediagnostics) is disabled. Only values that can be seen in the template are checked: inline functions, `new` expressions, and functions or classes declared at the top level of `<script setup>`.
12
+
13
+ ## Resolution
14
+
15
+ Pass only JSON-serializable values (strings, numbers, booleans, `null`, arrays and plain objects), and move the logic that needs the function into the server component:
16
+
17
+ ```diff [app/pages/index.vue]
18
+ <template>
19
+ - <PriceTag :format="value => `$${value}`" :value="price" />
20
+ + <PriceTag currency="USD" :value="price" />
21
+ </template>
22
+ ```
23
+
24
+ If the component needs a function from its parent, render it on the client instead of as a server component.
25
+
26
+ ::read-more{to="/docs/guide/concepts/server-components"}
27
+ ::
@@ -0,0 +1,31 @@
1
+ ---
2
+ title: 'NUXT_B4025'
3
+ description: 'NuxtLink to an unknown route'
4
+ navigation: false
5
+ ---
6
+
7
+ # B4025
8
+
9
+ A template contains a `<NuxtLink>` with a static `to` (or `href`) that does not match any page route, so following the link would show a 404 page.
10
+
11
+ This warning is reported unless [`experimental.templateDiagnostics`](/docs/guide/going-further/experimental-features#templatediagnostics) is disabled. Only static, absolute paths are checked: links with a bound `:to`, external URLs, relative paths, hash-only and query-only links, and links with the `external` prop are not. Dynamic route segments and catch-all routes match any value, and paths that a route rule redirects are accepted.
12
+
13
+ A path that only matches as the prefix of a route is reported: with only `app/pages/users/[id].vue`, a link to `/users` has no page to render.
14
+
15
+ ## Resolution
16
+
17
+ Check the path for typos, or add the page it should link to. If the link points at something other than a page (a server route, a file in `public/`, or another app on the same domain), set the `external` prop so that it is followed by the browser rather than the Vue router:
18
+
19
+ ```vue
20
+ <template>
21
+ <NuxtLink
22
+ to="/api/export.csv"
23
+ external
24
+ >
25
+ Download
26
+ </NuxtLink>
27
+ </template>
28
+ ```
29
+
30
+ ::read-more{to="/docs/api/components/nuxt-link"}
31
+ ::
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/docs-nightly",
3
- "version": "5.0.0-2610271652-3b4f925",
3
+ "version": "5.0.0-2610272000-c73c4e1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",