@nuxt/docs 3.17.3 → 4.0.0-0

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.
@@ -148,7 +148,9 @@ If you only need to modify the `<head>`, you can refer to the [SEO and meta sect
148
148
  You can have full control over the HTML template by adding a Nitro plugin that registers a hook.
149
149
  The callback function of the `render:html` hook allows you to mutate the HTML before it is sent to the client.
150
150
 
151
- ```ts twoslash [server/plugins/extend-html.ts]
151
+ <!-- TODO: figure out how to use twoslash to inject types for a different context -->
152
+
153
+ ```ts [server/plugins/extend-html.ts]
152
154
  export default defineNitroPlugin((nitroApp) => {
153
155
  nitroApp.hooks.hook('render:html', (html, { event }) => {
154
156
  // This will be an object representation of the html template.
@@ -153,7 +153,9 @@ If you need more advanced control, you can intercept the rendered html with a ho
153
153
 
154
154
  Create a plugin in `~/server/plugins/my-plugin.ts` like this:
155
155
 
156
- ```ts twoslash [server/plugins/my-plugin.ts]
156
+ <!-- TODO: figure out how to use twoslash to inject types for a different context -->
157
+
158
+ ```ts [server/plugins/my-plugin.ts]
157
159
  export default defineNitroPlugin((nitro) => {
158
160
  nitro.hooks.hook('render:html', (html) => {
159
161
  html.head.push('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">')
@@ -610,7 +610,7 @@ onMounted(() => console.log(document.cookie))
610
610
  </script>
611
611
  ```
612
612
 
613
- ## Options API support
613
+ ## Options API Support
614
614
 
615
615
  Nuxt provides a way to perform `asyncData` fetching within the Options API. You must wrap your component definition within `defineNuxtComponent` for this to work.
616
616
 
@@ -744,7 +744,7 @@ const { data } = await useFetch('/api/superjson', {
744
744
 
745
745
  ## Recipes
746
746
 
747
- ### Consuming SSE (Server Sent Events) via POST request
747
+ ### Consuming SSE (Server-Sent Events) via POST request
748
748
 
749
749
  ::tip
750
750
  If you're consuming SSE via GET request, you can use [`EventSource`](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) or VueUse composable [`useEventSource`](https://vueuse.org/core/useEventSource/).
@@ -594,7 +594,7 @@ For local development or automated deploy pipelines, testing against a separate
594
594
 
595
595
  To utilize a separate target host for end-to-end tests, simply provide the `host` property of the `setup` function with the desired URL.
596
596
 
597
- ```ts twoslash
597
+ ```ts
598
598
  import { setup, createPage } from '@nuxt/test-utils/e2e'
599
599
  import { describe, it, expect } from 'vitest'
600
600
 
@@ -621,6 +621,7 @@ You can automate this step by running `npx codemod@latest nuxt/4/default-data-er
621
621
  If you encounter any issues you can revert back to the previous behavior with:
622
622
 
623
623
  ```ts twoslash [nuxt.config.ts]
624
+ // @errors: 2353
624
625
  export default defineNuxtConfig({
625
626
  experimental: {
626
627
  defaults: {
@@ -644,6 +645,7 @@ Please report an issue if you are doing this, as we do not plan to keep this as
644
645
  Previously it was possible to pass `dedupe: boolean` to `refresh`. These were aliases of `cancel` (`true`) and `defer` (`false`).
645
646
 
646
647
  ```ts twoslash [app.vue]
648
+ // @errors: 2322
647
649
  const { refresh } = await useAsyncData(async () => ({ message: 'Hello, Nuxt!' }))
648
650
 
649
651
  async function refreshData () {
@@ -657,7 +659,7 @@ These aliases were removed, for greater clarity.
657
659
 
658
660
  The issue came up when adding `dedupe` as an option to `useAsyncData`, and we removed the boolean values as they ended up being _opposites_.
659
661
 
660
- `refresh({ dedupe: false })` meant 'do not _cancel_ existing requests in favour of this new one'. But passing `dedupe: true` within the options of `useAsyncData` means 'do not make any new requests if there is an existing pending request.' (See [PR](https://github.com/nuxt/nuxt/pull/24564#pullrequestreview-1764584361).)
662
+ `refresh({ dedupe: false })` meant **do not _cancel_ existing requests in favour of this new one**. But passing `dedupe: true` within the options of `useAsyncData` means **do not make any new requests if there is an existing pending request.** (See [PR](https://github.com/nuxt/nuxt/pull/24564#pullrequestreview-1764584361).)
661
663
 
662
664
  #### Migration Steps
663
665
 
@@ -696,6 +698,7 @@ Often users set an appropriately empty value, such as an empty array, to avoid t
696
698
  If you encounter any issues you can revert back to the previous behavior, for now, with:
697
699
 
698
700
  ```ts twoslash [nuxt.config.ts]
701
+ // @errors: 2353
699
702
  export default defineNuxtConfig({
700
703
  experimental: {
701
704
  resetAsyncDataToUndefined: true,
@@ -335,6 +335,10 @@ You may define a name for this page's route.
335
335
 
336
336
  You may define a path matcher, if you have a more complex pattern than can be expressed with the file name. See [the `vue-router` docs](https://router.vuejs.org/guide/essentials/route-matching-syntax.html#custom-regex-in-params) for more information.
337
337
 
338
+ #### `props`
339
+
340
+ Allows accessing the route `params` as props passed to the page component. See[the `vue-router` docs](https://router.vuejs.org/guide/essentials/passing-props) for more information.
341
+
338
342
  ### Typing Custom Metadata
339
343
 
340
344
  If you add custom metadata for your pages, you may wish to do so in a type-safe way. It is possible to augment the type of the object accepted by `definePageMeta`:
@@ -74,7 +74,7 @@ declare module '#app' {
74
74
  }
75
75
  }
76
76
 
77
- declare module 'nitropack' {
77
+ declare module 'nitro/types' {
78
78
  interface NitroRuntimeHooks {
79
79
  'your-nitro-hook': () => void;
80
80
  }
@@ -57,25 +57,11 @@ export default defineNuxtConfig({
57
57
  This feature will likely be removed in a near future.
58
58
  ::
59
59
 
60
- ## treeshakeClientOnly
61
-
62
- Tree shakes contents of client-only components from server bundle.
63
-
64
- *Enabled by default.*
65
-
66
- ```ts twoslash [nuxt.config.ts]
67
- export default defineNuxtConfig({
68
- experimental: {
69
- treeshakeClientOnly: true
70
- }
71
- })
72
- ```
73
-
74
60
  ## emitRouteChunkError
75
61
 
76
62
  Emits `app:chunkError` hook when there is an error loading vite/webpack chunks. Default behavior is to perform a reload of the new route on navigation to a new route when a chunk fails to load.
77
63
 
78
- If you set this to `'automatic-immediate'` Nuxt will reload the current route immediatly, instead of waiting for a navigation. This is useful for chunk errors that are not triggered by navigation, e.g., when your Nuxt app fails to load a [lazy component](/docs/guide/directory-structure/components#dynamic-imports). A potential downside of this behavior is undesired reloads, e.g., when your app does not need the chunk that caused the error.
64
+ If you set this to `'automatic-immediate'` Nuxt will reload the current route immediately, instead of waiting for a navigation. This is useful for chunk errors that are not triggered by navigation, e.g., when your Nuxt app fails to load a [lazy component](/docs/guide/directory-structure/components#dynamic-imports). A potential downside of this behavior is undesired reloads, e.g., when your app does not need the chunk that caused the error.
79
65
 
80
66
  You can disable automatic handling by setting this to `false`, or handle chunk errors manually by setting it to `manual`.
81
67
 
@@ -240,44 +226,6 @@ export default defineNuxtConfig({
240
226
  You can follow the server components roadmap on GitHub.
241
227
  ::
242
228
 
243
- ## configSchema
244
-
245
- Enables config schema support.
246
-
247
- *Enabled by default.*
248
-
249
- ```ts twoslash [nuxt.config.ts]
250
- export default defineNuxtConfig({
251
- experimental: {
252
- configSchema: true
253
- }
254
- })
255
- ```
256
-
257
- ## polyfillVueUseHead
258
-
259
- Adds a compatibility layer for modules, plugins, or user code relying on the old `@vueuse/head` API.
260
-
261
- ```ts twoslash [nuxt.config.ts]
262
- export default defineNuxtConfig({
263
- experimental: {
264
- polyfillVueUseHead: false
265
- }
266
- })
267
- ```
268
-
269
- ## respectNoSSRHeader
270
-
271
- Allow disabling Nuxt SSR responses by setting the `x-nuxt-no-ssr` header.
272
-
273
- ```ts twoslash [nuxt.config.ts]
274
- export default defineNuxtConfig({
275
- experimental: {
276
- respectNoSSRHeader: false
277
- }
278
- })
279
- ```
280
-
281
229
  ## localLayerAliases
282
230
 
283
231
  Resolve `~`, `~~`, `@` and `@@` aliases located within layers with respect to their layer source and root directories.
@@ -614,7 +614,7 @@ export default defineNuxtModule({
614
614
  interface MyModuleNitroRules {
615
615
  myModule?: { foo: 'bar' }
616
616
  }
617
- declare module 'nitropack' {
617
+ declare module 'nitro/types' {
618
618
  interface NitroRouteRules extends MyModuleNitroRules {}
619
619
  interface NitroRouteConfig extends MyModuleNitroRules {}
620
620
  }
@@ -162,7 +162,7 @@ export default defineNuxtRouteMiddleware(() => {
162
162
 
163
163
  ## Home Page
164
164
 
165
- Now that we have our app middleware to protect our routes, we can use it on our home page that display our authenticated user informations. If the user is not authenticated, they will be redirected to the login page.
165
+ Now that we have our app middleware to protect our routes, we can use it on our home page that display our authenticated user information. If the user is not authenticated, they will be redirected to the login page.
166
166
 
167
167
  We'll use [`definePageMeta`](/docs/api/utils/define-page-meta) to apply the middleware to the route that we want to protect.
168
168
 
@@ -98,7 +98,7 @@ The `handler` function should be **side-effect free** to ensure predictable beha
98
98
  Which only caches data when `experimental.payloadExtraction` of `nuxt.config` is enabled.
99
99
  - `pick`: only pick specified keys in this array from the `handler` function result
100
100
  - `watch`: watch reactive sources to auto-refresh
101
- - `deep`: return data in a deep ref object (it is `true` by default). It can be set to `false` to return data in a shallow ref object, which can improve performance if your data does not need to be deeply reactive.
101
+ - `deep`: return data in a deep ref object. It is `false` by default to return data in a shallow ref object for performance.
102
102
  - `dedupe`: avoid fetching same key more than once at a time (defaults to `cancel`). Possible options:
103
103
  - `cancel` - cancels existing requests when a new one is made
104
104
  - `defer` - does not make new requests at all if there is a pending request
@@ -132,7 +132,7 @@ All fetch options can be given a `computed` or `ref` value. These will be watche
132
132
  Which only caches data when `experimental.payloadExtraction` of `nuxt.config` is enabled.
133
133
  - `pick`: only pick specified keys in this array from the `handler` function result
134
134
  - `watch`: watch an array of reactive sources and auto-refresh the fetch result when they change. Fetch options and URL are watched by default. You can completely ignore reactive sources by using `watch: false`. Together with `immediate: false`, this allows for a fully-manual `useFetch`. (You can [see an example here](/docs/getting-started/data-fetching#watch) of using `watch`.)
135
- - `deep`: return data in a deep ref object (it is `true` by default). It can be set to `false` to return data in a shallow ref object, which can improve performance if your data does not need to be deeply reactive.
135
+ - `deep`: return data in a deep ref object. It is `false` by default to return data in a shallow ref object for performance.
136
136
  - `dedupe`: avoid fetching same key more than once at a time (defaults to `cancel`). Possible options:
137
137
  - `cancel` - cancels existing requests when a new one is made
138
138
  - `defer` - does not make new requests at all if there is a pending request
@@ -108,5 +108,5 @@ async function addTodo () {
108
108
  ## Type
109
109
 
110
110
  ```ts
111
- useNuxtData<DataT = any> (key: string): { data: Ref<DataT | null> }
111
+ useNuxtData<DataT = any> (key: string): { data: Ref<DataT | undefined> }
112
112
  ```
@@ -117,7 +117,7 @@ export default defineNuxtModule({
117
117
 
118
118
  ```ts twoslash
119
119
  // @errors: 2391
120
- import type { NitroDevEventHandler } from 'nitropack'
120
+ import type { NitroDevEventHandler } from 'nitro/types'
121
121
  // ---cut---
122
122
  function addDevServerHandler (handler: NitroDevEventHandler): void
123
123
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/docs",
3
- "version": "3.17.3",
3
+ "version": "4.0.0-0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",