@nuxt/docs 3.17.3 → 3.17.4
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.
- package/1.getting-started/02.installation.md +1 -1
- package/1.getting-started/03.configuration.md +2 -2
- package/1.getting-started/06.styling.md +1 -1
- package/1.getting-started/10.data-fetching.md +2 -2
- package/1.getting-started/17.testing.md +1 -1
- package/1.getting-started/18.upgrade.md +1 -1
- package/2.guide/2.directory-structure/1.composables.md +6 -6
- package/2.guide/2.directory-structure/1.pages.md +3 -3
- package/3.api/2.composables/use-nuxt-data.md +1 -1
- package/package.json +1 -1
|
@@ -21,7 +21,7 @@ Or follow the steps below to set up a new Nuxt project on your computer.
|
|
|
21
21
|
<!-- markdownlint-disable-next-line MD001 -->
|
|
22
22
|
#### Prerequisites
|
|
23
23
|
|
|
24
|
-
- **Node.js** - [`
|
|
24
|
+
- **Node.js** - [`20.x`](https://nodejs.org/en) or newer (but we recommend the [active LTS release](https://github.com/nodejs/release#release-schedule))
|
|
25
25
|
- **Text editor** - There is no IDE requirement, but we recommend [Visual Studio Code](https://code.visualstudio.com/) with the [official Vue extension](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (previously known as Volar) or [WebStorm](https://www.jetbrains.com/webstorm/), which, along with [other JetBrains IDEs](https://www.jetbrains.com/ides/), offers great Nuxt support right out-of-the-box.
|
|
26
26
|
- **Terminal** - In order to run Nuxt commands
|
|
27
27
|
|
|
@@ -171,8 +171,8 @@ Name | Config File | How To
|
|
|
171
171
|
|
|
172
172
|
If you need to pass options to `@vitejs/plugin-vue` or `@vitejs/plugin-vue-jsx`, you can do this in your `nuxt.config` file.
|
|
173
173
|
|
|
174
|
-
- `vite.vue` for `@vitejs/plugin-vue`. Check available options
|
|
175
|
-
- `vite.vueJsx` for `@vitejs/plugin-vue-jsx`. Check available options
|
|
174
|
+
- `vite.vue` for `@vitejs/plugin-vue`. Check [available options](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue).
|
|
175
|
+
- `vite.vueJsx` for `@vitejs/plugin-vue-jsx`. Check [available options](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx).
|
|
176
176
|
|
|
177
177
|
```ts twoslash [nuxt.config.ts]
|
|
178
178
|
export default defineNuxtConfig({
|
|
@@ -145,7 +145,7 @@ useHead({
|
|
|
145
145
|
})
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
Nuxt uses `unhead` under the hood, and you can refer to its full documentation
|
|
148
|
+
Nuxt uses `unhead` under the hood, and you can refer to [its full documentation](https://unhead.unjs.io).
|
|
149
149
|
|
|
150
150
|
### Modifying The Rendered Head With A Nitro Plugin
|
|
151
151
|
|
|
@@ -610,7 +610,7 @@ onMounted(() => console.log(document.cookie))
|
|
|
610
610
|
</script>
|
|
611
611
|
```
|
|
612
612
|
|
|
613
|
-
## Options API
|
|
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
|
|
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/).
|
|
@@ -280,7 +280,7 @@ mockNuxtImport('useStorage', () => {
|
|
|
280
280
|
```
|
|
281
281
|
|
|
282
282
|
::note
|
|
283
|
-
`mockNuxtImport` can only be used once per mocked import per test file. It is actually a macro that gets transformed to `vi.mock` and `vi.mock` is hoisted, as described [
|
|
283
|
+
`mockNuxtImport` can only be used once per mocked import per test file. It is actually a macro that gets transformed to `vi.mock` and `vi.mock` is hoisted, as described [in the Vitest docs](https://vitest.dev/api/vi.html#vi-mock).
|
|
284
284
|
::
|
|
285
285
|
|
|
286
286
|
If you need to mock a Nuxt import and provide different implementations between tests, you can do it by creating and exposing your mocks using [`vi.hoisted`](https://vitest.dev/api/vi.html#vi-hoisted), and then use those mocks in `mockNuxtImport`. You then have access to the mocked imports, and can change the implementation between tests. Be careful to [restore mocks](https://vitest.dev/api/mock.html#mockrestore) before or after each test to undo mock state changes between runs.
|
|
@@ -657,7 +657,7 @@ These aliases were removed, for greater clarity.
|
|
|
657
657
|
|
|
658
658
|
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
659
|
|
|
660
|
-
`refresh({ dedupe: false })` meant
|
|
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).)
|
|
661
661
|
|
|
662
662
|
#### Migration Steps
|
|
663
663
|
|
|
@@ -109,12 +109,12 @@ export { utils } from './nested/utils.ts'
|
|
|
109
109
|
export default defineNuxtConfig({
|
|
110
110
|
imports: {
|
|
111
111
|
dirs: [
|
|
112
|
-
// Scan top-level
|
|
113
|
-
'composables',
|
|
114
|
-
// ... or scan
|
|
115
|
-
'composables/*/index.{ts,js,mjs,mts}',
|
|
116
|
-
// ... or scan all
|
|
117
|
-
'composables/**'
|
|
112
|
+
// Scan top-level composables
|
|
113
|
+
'~/composables',
|
|
114
|
+
// ... or scan composables nested one level deep with a specific name and file extension
|
|
115
|
+
'~/composables/*/index.{ts,js,mjs,mts}',
|
|
116
|
+
// ... or scan all composables within given directory
|
|
117
|
+
'~/composables/**'
|
|
118
118
|
]
|
|
119
119
|
}
|
|
120
120
|
})
|
|
@@ -299,13 +299,13 @@ Of course, you are welcome to define metadata for your own use throughout your a
|
|
|
299
299
|
|
|
300
300
|
#### `alias`
|
|
301
301
|
|
|
302
|
-
You can define page aliases. They allow you to access the same page from different paths. It can be either a string or an array of strings as defined [
|
|
302
|
+
You can define page aliases. They allow you to access the same page from different paths. It can be either a string or an array of strings as defined [in the vue-router documentation](https://router.vuejs.org/guide/essentials/redirect-and-alias.html#Alias).
|
|
303
303
|
|
|
304
304
|
#### `keepalive`
|
|
305
305
|
|
|
306
306
|
Nuxt will automatically wrap your page in [the Vue `<KeepAlive>` component](https://vuejs.org/guide/built-ins/keep-alive.html#keepalive) if you set `keepalive: true` in your `definePageMeta`. This might be useful to do, for example, in a parent route that has dynamic child routes, if you want to preserve page state across route changes.
|
|
307
307
|
|
|
308
|
-
When your goal is to preserve state for parent routes use this syntax: `<NuxtPage keepalive />`. You can also set props to be passed to `<KeepAlive>` (see a full list
|
|
308
|
+
When your goal is to preserve state for parent routes use this syntax: `<NuxtPage keepalive />`. You can also set props to be passed to `<KeepAlive>` (see [a full list](https://vuejs.org/api/built-in-components.html#keepalive)).
|
|
309
309
|
|
|
310
310
|
You can set a default value for this property [in your `nuxt.config`](/docs/api/nuxt-config#keepalive).
|
|
311
311
|
|
|
@@ -319,7 +319,7 @@ You can define the layout used to render the route. This can be either false (to
|
|
|
319
319
|
|
|
320
320
|
#### `layoutTransition` and `pageTransition`
|
|
321
321
|
|
|
322
|
-
You can define transition properties for the `<transition>` component that wraps your pages and layouts, or pass `false` to disable the `<transition>` wrapper for that route. You can see a list of options that can be passed
|
|
322
|
+
You can define transition properties for the `<transition>` component that wraps your pages and layouts, or pass `false` to disable the `<transition>` wrapper for that route. You can see [a list of options that can be passed](https://vuejs.org/api/built-in-components.html#transition) or read [more about how transitions work](https://vuejs.org/guide/built-ins/transition.html#transition).
|
|
323
323
|
|
|
324
324
|
You can set default values for these properties [in your `nuxt.config`](/docs/api/nuxt-config#layouttransition).
|
|
325
325
|
|