@nuxt/docs 3.21.1 → 3.21.2

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.
@@ -20,13 +20,14 @@ Or follow the steps below to set up a new Nuxt project on your computer.
20
20
  ### Prerequisites
21
21
 
22
22
  - **Node.js** - [`20.x`](https://nodejs.org/en) or newer (but we recommend the [active LTS release](https://github.com/nodejs/release#release-schedule))
23
- - **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.
23
+ - **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. If you use another editor, such as Neovim, you can configure [Vue Language Server](https://github.com/vuejs/language-tools) support by following the [Vue Language Tools setup guides](https://github.com/vuejs/language-tools/wiki).
24
24
  - **Terminal** - In order to run Nuxt commands
25
25
 
26
26
  ::note
27
27
  ::details
28
28
  :summary[Additional notes for an optimal setup:]
29
29
  - **Node.js**: Make sure to use an even numbered version (20, 22, etc.)
30
+ - **Neovim**: When configuring the Vue TypeScript plugin, make sure `location` points to the `@vue/language-server` package directory, not its binary. See the [Neovim setup guide](https://github.com/vuejs/language-tools/wiki/Neovim) for a working configuration.
30
31
  - **WSL**: If you are using Windows and experience slow HMR, you may want to try using [WSL (Windows Subsystem for Linux)](https://learn.microsoft.com/en-us/windows/wsl/install) which may solve some performance issues.
31
32
  - **Windows slow DNS resolution**: Instead of using `localhost:3000` for local dev server on Windows, use `127.0.0.1` for much faster loading experience on browsers.
32
33
  ::
@@ -155,7 +155,7 @@ Nuxt uses `unhead` under the hood, and you can refer to [its full documentation]
155
155
 
156
156
  If you need more advanced control, you can intercept the rendered html with a hook and modify the head programmatically.
157
157
 
158
- Create a plugin in `~/server/plugins/my-plugin.ts` like this:
158
+ Create a plugin in `~~/server/plugins/my-plugin.ts` like this:
159
159
 
160
160
  <!-- TODO: figure out how to use twoslash to inject types for a different context -->
161
161
 
@@ -120,9 +120,8 @@ In most cases, Nuxt can work with third-party content that is not generated or c
120
120
 
121
121
  Accordingly, you should make sure that the following options are unchecked / disabled in Cloudflare. Otherwise, unnecessary re-rendering or hydration errors could impact your production application.
122
122
 
123
- 1. Speed > Optimization > Content Optimization > Disable "Rocket Loader™"
124
- 2. Speed > Optimization > Image Optimization > Disable "Mirage"
125
- 3. Scrape Shield > Disable "Email Address Obfuscation"
123
+ 1. Speed > Settings > Content Optimization > Disable "Rocket Loader™"
124
+ 2. Security > Settings > Disable "Email Address Obfuscation"
126
125
 
127
126
  With these settings, you can be sure that Cloudflare won't inject scripts into your Nuxt application that may cause unwanted side effects.
128
127
 
@@ -108,6 +108,7 @@ If you prefer a simpler setup and want all tests to run in the Nuxt environment,
108
108
 
109
109
  ```ts twoslash
110
110
  import { defineVitestConfig } from '@nuxt/test-utils/config'
111
+ import { fileURLToPath } from 'node:url'
111
112
 
112
113
  export default defineVitestConfig({
113
114
  test: {
@@ -268,6 +269,10 @@ it('can also mount an app', async () => {
268
269
  })
269
270
  ```
270
271
 
272
+ The options object accepts `@vue/test-utils` mount options and the following properties:
273
+
274
+ - `route`: the initial route, or `false` to skip the initial route change (default `/`).
275
+
271
276
  #### `renderSuspended`
272
277
 
273
278
  `renderSuspended` allows you to render any Vue component within the Nuxt environment using `@testing-library/vue`, allowing async setup and access to injections from your Nuxt plugins.
@@ -320,14 +325,18 @@ it('can also render an app', async () => {
320
325
  })
321
326
  ```
322
327
 
328
+ The options object accepts `@testing-library/vue` render options and the following properties:
329
+
330
+ - `route`: the initial route, or `false` to skip the initial route change (default `/`).
331
+
323
332
  #### `mockNuxtImport`
324
333
 
325
- `mockNuxtImport` allows you to mock Nuxt's auto import functionality. For example, to mock `useStorage`, you can do so like this:
334
+ `mockNuxtImport` allows you to mock Nuxt's auto import functionality. For example, to mock `useState`, you can do so like this:
326
335
 
327
336
  ```ts twoslash
328
337
  import { mockNuxtImport } from '@nuxt/test-utils/runtime'
329
338
 
330
- mockNuxtImport('useStorage', () => {
339
+ mockNuxtImport('useState', () => {
331
340
  return () => {
332
341
  return { value: 'mocked storage' }
333
342
  }
@@ -336,6 +345,27 @@ mockNuxtImport('useStorage', () => {
336
345
  // your tests here
337
346
  ```
338
347
 
348
+ You can explicitly type the mock for type safety, and use the original implementation passed to the factory function when mocking complex functionality.
349
+
350
+ ```ts twoslash [test/nuxt/import.test.ts]
351
+ import { mockNuxtImport } from '@nuxt/test-utils/runtime'
352
+
353
+ mockNuxtImport<typeof useState>('useState', (original) => {
354
+ return (...args) => {
355
+ return { ...original('some-key'), value: 'mocked state' }
356
+ }
357
+ })
358
+
359
+ // or specify the target to mock
360
+ mockNuxtImport(useState, (original) => {
361
+ return (...args) => {
362
+ return { ...original('some-key'), value: 'mocked state' }
363
+ }
364
+ })
365
+
366
+ // your tests here
367
+ ```
368
+
339
369
  ::note
340
370
  `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#vi-mock).
341
371
  ::
@@ -346,24 +376,43 @@ If you need to mock a Nuxt import and provide different implementations between
346
376
  import { vi } from 'vitest'
347
377
  import { mockNuxtImport } from '@nuxt/test-utils/runtime'
348
378
 
349
- const { useStorageMock } = vi.hoisted(() => {
379
+ const { useStateMock } = vi.hoisted(() => {
350
380
  return {
351
- useStorageMock: vi.fn(() => {
381
+ useStateMock: vi.fn(() => {
352
382
  return { value: 'mocked storage' }
353
383
  }),
354
384
  }
355
385
  })
356
386
 
357
- mockNuxtImport('useStorage', () => {
358
- return useStorageMock
387
+ mockNuxtImport('useState', () => {
388
+ return useStateMock
359
389
  })
360
390
 
361
391
  // Then, inside a test
362
- useStorageMock.mockImplementation(() => {
392
+ useStateMock.mockImplementation(() => {
363
393
  return { value: 'something else' }
364
394
  })
365
395
  ```
366
396
 
397
+ If you need to mock behavior only inside a test, you can also use the following approach.
398
+
399
+ ```ts twoslash
400
+ import { beforeEach, vi } from 'vitest'
401
+ import { mockNuxtImport } from '@nuxt/test-utils/runtime'
402
+
403
+ mockNuxtImport(useRoute, original => vi.fn(original))
404
+
405
+ beforeEach(() => {
406
+ vi.resetAllMocks()
407
+ })
408
+
409
+ // Then, inside a test
410
+ const useRouteOriginal = vi.mocked(useRoute).getMockImplementation()!
411
+ vi.mocked(useRoute).mockImplementation(
412
+ (...args) => ({ ...useRouteOriginal(...args), path: '/mocked' }),
413
+ )
414
+ ```
415
+
367
416
  #### `mockComponent`
368
417
 
369
418
  `mockComponent` allows you to mock Nuxt's component.
@@ -445,6 +494,12 @@ registerEndpoint('/test/', {
445
494
  })
446
495
  ```
447
496
 
497
+ This object accepts the following properties:
498
+
499
+ - `handler`: the event handler function
500
+ - `method`: (optional) HTTP method to match (e.g., 'GET', 'POST')
501
+ - `once`: (optional) if true, the handler will only be used for the first matching request and then automatically removed
502
+
448
503
  > **Note**: If your requests in a component go to an external API, you can use `baseURL` and then make it empty using [Nuxt Environment Override Config](/docs/3.x/getting-started/configuration#environment-overrides) (`$test`) so all your requests will go to Nitro server.
449
504
 
450
505
  #### Conflict with End-To-End Testing
@@ -458,7 +513,7 @@ If you would like to use both the end-to-end and unit testing functionality of `
458
513
  ```ts twoslash
459
514
  import { mockNuxtImport } from '@nuxt/test-utils/runtime'
460
515
 
461
- mockNuxtImport('useStorage', () => {
516
+ mockNuxtImport('useState', () => {
462
517
  return () => {
463
518
  return { value: 'mocked storage' }
464
519
  }
@@ -192,6 +192,7 @@ Nuxt now defaults to a new directory structure, with backwards compatibility (so
192
192
  - `layers/`, `modules/` and `public/` are resolved relative to `<rootDir>` by default
193
193
  - if using [Nuxt Content v2.13+](https://github.com/nuxt/content/pull/2649), `content/` is resolved relative to `<rootDir>`
194
194
  - a new `dir.app` is added, which is the directory we look for `router.options.ts` and `spa-loading-template.html` - this defaults to `<srcDir>/`
195
+ - a new [`shared/`](/docs/3.x/directory-structure/shared) directory is available for code shared between the Vue app and the Nitro server, with auto-imports for `shared/utils/` and `shared/types/`
195
196
 
196
197
  <details>
197
198
 
@@ -218,6 +219,8 @@ modules/
218
219
  node_modules/
219
220
  public/
220
221
  shared/
222
+ types/
223
+ utils/
221
224
  server/
222
225
  api/
223
226
  middleware/
@@ -246,14 +249,14 @@ With this new structure, the `~` alias now points to the `app/` directory by def
246
249
 
247
250
  1. Create a new directory called `app/`.
248
251
  1. Move your `assets/`, `components/`, `composables/`, `layouts/`, `middleware/`, `pages/`, `plugins/` and `utils/` folders under it, as well as `app.vue`, `error.vue`, `app.config.ts`. If you have an `app/router-options.ts` or `app/spa-loading-template.html`, these paths remain the same.
249
- 1. Make sure your `nuxt.config.ts`, `content/`, `layers/`, `modules/`, `public/` and `server/` folders remain outside the `app/` folder, in the root of your project.
252
+ 1. Make sure your `nuxt.config.ts`, `content/`, `layers/`, `modules/`, `public/`, `shared/` and `server/` folders remain outside the `app/` folder, in the root of your project.
250
253
  1. Remember to update any third-party configuration files to work with the new directory structure, such as your `tailwindcss` or `eslint` configuration (if required - `@nuxtjs/tailwindcss` should automatically configure `tailwindcss` correctly).
251
254
 
252
255
  ::tip
253
256
  You can automate this migration by running `npx codemod@latest nuxt/4/file-structure`
254
257
  ::
255
258
 
256
- However, migration is _not required_. If you wish to keep your current folder structure, Nuxt should auto-detect it. (If it does not, please raise an issue.) The one exception is that if you _already_ have a custom `srcDir`. In this case, you should be aware that your `modules/`, `public/` and `server/` folders will be resolved from your `rootDir` rather than from your custom `srcDir`. You can override this by configuring `dir.modules`, `dir.public` and `serverDir` if you need to.
259
+ However, migration is _not required_. If you wish to keep your current folder structure, Nuxt should auto-detect it. (If it does not, please raise an issue.) The one exception is that if you _already_ have a custom `srcDir`. In this case, you should be aware that your `modules/`, `public/`, `shared/` and `server/` folders will be resolved from your `rootDir` rather than from your custom `srcDir`. You can override this by configuring `dir.modules`, `dir.public` and `serverDir` if you need to.
257
260
 
258
261
  You can also force a v3 folder structure with the following configuration:
259
262
 
@@ -122,7 +122,7 @@ File | Layout Name
122
122
 
123
123
  You can also use the [`setPageLayout`](/docs/3.x/api/utils/set-page-layout) helper to change the layout dynamically:
124
124
 
125
- ```vue twoslash
125
+ ```vue twoslash [app/pages/index.vue]
126
126
  <script setup lang="ts">
127
127
  declare module 'nuxt/app' {
128
128
  interface NuxtLayouts {
@@ -52,6 +52,10 @@ export default defineEventHandler(() => {
52
52
 
53
53
  When starting Nuxt, the `hello` module will be registered and the `/api/hello` route will be available.
54
54
 
55
+ ::note
56
+ Note that all components, pages, composables and other files that would be normally placed in your `app/` directory need to be in `modules/your-module/runtime/app/`. This ensures they can be type-checked properly.
57
+ ::
58
+
55
59
  Modules are executed in the following sequence:
56
60
  - First, the modules defined in [`nuxt.config.ts`](/docs/3.x/api/nuxt-config#modules-1) are loaded.
57
61
  - Then, modules found in the `modules/` directory are executed, and they load in alphabetical order.
@@ -43,11 +43,11 @@ const { data } = await useFetch('/api/hello')
43
43
 
44
44
  ## Server Routes
45
45
 
46
- Files inside the `~/server/api` are automatically prefixed with `/api` in their route.
46
+ Files inside the `~~/server/api` are automatically prefixed with `/api` in their route.
47
47
 
48
48
  :video-accordion{title="Watch a video from Vue School on API routes" videoId="761468863" platform="vimeo"}
49
49
 
50
- To add server routes without `/api` prefix, put them into `~/server/routes` directory.
50
+ To add server routes without `/api` prefix, put them into `~~/server/routes` directory.
51
51
 
52
52
  **Example:**
53
53
 
@@ -63,7 +63,7 @@ Note that currently server routes do not support the full functionality of dynam
63
63
 
64
64
  ## Server Middleware
65
65
 
66
- Nuxt will automatically read in any file in the `~/server/middleware` to create server middleware for your project.
66
+ Nuxt will automatically read in any file in the `~~/server/middleware` to create server middleware for your project.
67
67
 
68
68
  Middleware handlers will run on every request before any other server route to add or check headers, log requests, or extend the event's request object.
69
69
 
@@ -87,7 +87,7 @@ export default defineEventHandler((event) => {
87
87
 
88
88
  ## Server Plugins
89
89
 
90
- Nuxt will automatically read any files in the `~/server/plugins` directory and register them as Nitro plugins. This allows extending Nitro's runtime behavior and hooking into lifecycle events.
90
+ Nuxt will automatically read any files in the `~~/server/plugins` directory and register them as Nitro plugins. This allows extending Nitro's runtime behavior and hooking into lifecycle events.
91
91
 
92
92
  **Example:**
93
93
 
@@ -105,7 +105,7 @@ Server routes are powered by [h3js/h3](https://github.com/h3js/h3) which comes w
105
105
 
106
106
  :read-more{to="https://www.jsdocs.io/package/h3#package-index-functions" title="Available H3 Request Helpers" target="_blank"}
107
107
 
108
- You can add more helpers yourself inside the `~/server/utils` directory.
108
+ You can add more helpers yourself inside the `~~/server/utils` directory.
109
109
 
110
110
  For example, you can define a custom handler utility that wraps the original handler and performs additional operations before returning the final response.
111
111
 
@@ -228,7 +228,7 @@ export default defineEventHandler((event) => {
228
228
 
229
229
  Catch-all routes are helpful for fallback route handling.
230
230
 
231
- For example, creating a file named `~/server/api/foo/[...].ts` will register a catch-all route for all requests that do not match any route handler, such as `/api/foo/bar/baz`.
231
+ For example, creating a file named `~~/server/api/foo/[...].ts` will register a catch-all route for all requests that do not match any route handler, such as `/api/foo/bar/baz`.
232
232
 
233
233
  ```ts [server/api/foo/[...\\].ts]
234
234
  export default defineEventHandler((event) => {
@@ -238,7 +238,7 @@ export default defineEventHandler((event) => {
238
238
  })
239
239
  ```
240
240
 
241
- You can set a name for the catch-all route by using `~/server/api/foo/[...slug].ts` and access it via `event.context.params.slug`.
241
+ You can set a name for the catch-all route by using `~~/server/api/foo/[...slug].ts` and access it via `event.context.params.slug`.
242
242
 
243
243
  ```ts [server/api/foo/[...slug\\].ts]
244
244
  export default defineEventHandler((event) => {
@@ -6,32 +6,32 @@ description: Why fixing hydration issues is important
6
6
 
7
7
  When developing, you may face hydration issues. Don't ignore those warnings.
8
8
 
9
- # Why is it important to fix them?
9
+ ## Why is it important to fix them?
10
10
 
11
11
  Hydration mismatches are not just warnings - they are indicators of serious problems that can break your application:
12
12
 
13
- ## Performance Impact
13
+ ### Performance Impact
14
14
 
15
15
  - **Increased time to interactive**: Hydration errors force Vue to re-render the entire component tree, which will increase the time for your Nuxt app to become interactive
16
16
  - **Poor user experience**: Users may see content flashing or unexpected layout shifts
17
17
 
18
- ## Functionality Issues
18
+ ### Functionality Issues
19
19
 
20
20
  - **Broken interactivity**: Event listeners may not attach properly, leaving buttons and forms non-functional
21
21
  - **State inconsistencies**: Application state can become out of sync between what the user sees and what the application thinks is rendered
22
22
  - **SEO problems**: Search engines may index different content than what users actually see
23
23
 
24
- # How to detect them
24
+ ## How to detect them
25
25
 
26
- ## Development Console Warnings
26
+ ### Development Console Warnings
27
27
 
28
28
  Vue will log hydration mismatch warnings in the browser console during development:
29
29
 
30
30
  ![Screenshot of Vue hydration mismatch warning in the browser console](/assets/docs/best-practices/vue-console-hydration.png)
31
31
 
32
- # Common reasons
32
+ ## Common reasons
33
33
 
34
- ## Browser-only APIs in Server Context
34
+ ### Browser-only APIs in Server Context
35
35
 
36
36
  **Problem**: Using browser-specific APIs during server-side rendering.
37
37
 
@@ -60,7 +60,7 @@ const userTheme = useCookie('theme', { default: () => 'light' })
60
60
  </script>
61
61
  ```
62
62
 
63
- ## Inconsistent Data
63
+ ### Inconsistent Data
64
64
 
65
65
  **Problem**: Different data between server and client.
66
66
 
@@ -82,7 +82,7 @@ const state = useState('random', () => Math.random())
82
82
  </script>
83
83
  ```
84
84
 
85
- ## Conditional Rendering Based on Client State
85
+ ### Conditional Rendering Based on Client State
86
86
 
87
87
  **Problem**: Using client-only conditions during SSR.
88
88
 
@@ -105,7 +105,7 @@ const state = useState('random', () => Math.random())
105
105
  </template>
106
106
  ```
107
107
 
108
- ## Third-party Libraries with Side Effects
108
+ ### Third-party Libraries with Side Effects
109
109
 
110
110
  **Problem**: Libraries that modify the DOM or have browser dependencies (this happens a LOT with tag managers).
111
111
 
@@ -129,7 +129,7 @@ onMounted(async () => {
129
129
  </script>
130
130
  ```
131
131
 
132
- ## Dynamic Content Based on Time
132
+ ### Dynamic Content Based on Time
133
133
 
134
134
  **Problem**: Content that changes based on current time.
135
135
 
@@ -142,9 +142,8 @@ Images in your website can usually be separated by importance; the ones that are
142
142
  <NuxtImg
143
143
  src="/hero-banner.jpg"
144
144
  format="webp"
145
- preload
145
+ :preload="{ fetchPriority: 'high' }"
146
146
  loading="eager"
147
- fetch-priority="high"
148
147
  width="200"
149
148
  height="100"
150
149
  />
@@ -154,7 +153,7 @@ Images in your website can usually be separated by importance; the ones that are
154
153
  src="/facebook-logo.jpg"
155
154
  format="webp"
156
155
  loading="lazy"
157
- fetch-priority="low"
156
+ fetchpriority="low"
158
157
  width="200"
159
158
  height="100"
160
159
  />
@@ -79,7 +79,7 @@ The Nuxt connector will appear in the composer's "Developer mode" tool later dur
79
79
  ### Claude Code
80
80
 
81
81
  ::note{icon="i-lucide-info"}
82
- **Ensure Claude Code is installed** - Visit [Anthropic's documentation](https://docs.claude.com/en/docs/claude-code/quickstart) for installation instructions.
82
+ **Ensure Claude Code is installed** - Visit [Anthropic's documentation](https://code.claude.com/docs/en/quickstart) for installation instructions.
83
83
  ::
84
84
 
85
85
  Add the server using the CLI command:
@@ -42,7 +42,7 @@ Nuxt provides specialized LLMs.txt files that you can reference in Cursor for be
42
42
  1. **Direct reference**: Mention the LLMs.txt URLs when asking questions
43
43
  2. Add these specific URLs to your project context using `@docs`
44
44
 
45
- [Read more about Cursor Web and Docs Search](https://cursor.com/docs/context/symbols)
45
+ [Read more about Cursor Web and Docs Search](https://cursor.com/docs/context/mentions)
46
46
 
47
47
  ### Windsurf
48
48
 
@@ -139,6 +139,10 @@ It is highly recommended to prefix your exports to avoid conflicts with user cod
139
139
  Note that all components, pages, composables and other files that would be normally placed in your `app/` folder need to be in `runtime/app/`. This will mean they can be type checked properly.
140
140
  ::
141
141
 
142
+ ::note
143
+ Note that all components, pages, composables and other files that would be normally placed in your `app/` folder need to be in `runtime/app/`. This will mean they can be type checked properly.
144
+ ::
145
+
142
146
  ## Add Composables
143
147
 
144
148
  If your module should provide composables, you can use the `addImports` utility to add them as auto-imports for Nuxt to resolve.
@@ -290,6 +294,10 @@ function setup () {
290
294
  ```
291
295
  ::
292
296
 
297
+ ::note
298
+ Note that all components, pages, composables and other files that would be normally placed in your `app/` folder need to be in `runtime/app/`. This will mean they can be type checked properly.
299
+ ::
300
+
293
301
  ## Add Server Routes
294
302
 
295
303
  ```ts
@@ -210,7 +210,7 @@ We've successfully set up a very basic user authentication and session managemen
210
210
 
211
211
  As next steps, you can:
212
212
  - Add authentication using the [20+ supported OAuth providers](https://github.com/atinux/nuxt-auth-utils?tab=readme-ov-file#supported-oauth-providers)
213
- - Add a database to store users, see [Nitro SQL Database](https://nitro.build/guide/database) or [NuxtHub SQL Database](https://hub.nuxt.com/docs/features/database)
213
+ - Add a database to store users, see [Nitro SQL Database](https://nitro.build/guide/database) or [NuxtHub SQL Database](https://hub.nuxt.com/docs/database)
214
214
  - Let user signup with email & password using [password hashing](https://github.com/atinux/nuxt-auth-utils?tab=readme-ov-file#password-hashing)
215
215
  - Add support for [WebAuthn / Passkeys](https://github.com/atinux/nuxt-auth-utils?tab=readme-ov-file#webauthn-passkey)
216
216
 
@@ -370,7 +370,11 @@ Out of the box, this will enable typed usage of [`navigateTo`](/docs/3.x/api/uti
370
370
  You can even get typed params within a page by using `const route = useRoute('route-name')`.
371
371
 
372
372
  ::important
373
- If you use `pnpm` without `shamefully-hoist=true`, you will need to have `unplugin-vue-router` installed as a devDependency in order for this feature to work.
373
+ 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.
374
+ ```yaml
375
+ publicHoistPattern:
376
+ - "unplugin-vue-router"
377
+ ```
374
378
  ::
375
379
 
376
380
  :video-accordion{title="Watch a video from Daniel Roe explaining type-safe routing in Nuxt" videoId="SXk-L19gTZk"}
@@ -57,7 +57,7 @@ Explore all available App hooks.
57
57
 
58
58
  These hooks are available for [server plugins](/docs/3.x/directory-structure/server#server-plugins) to hook into Nitro's runtime behavior.
59
59
 
60
- ```ts [~/server/plugins/test.ts]
60
+ ```ts [~~/server/plugins/test.ts]
61
61
  export default defineNitroPlugin((nitroApp) => {
62
62
  nitroApp.hooks.hook('render:html', (html, { event }) => {
63
63
  console.log('render:html', html)
@@ -74,4 +74,4 @@ Some slots are reserved to `NuxtIsland` for special cases.
74
74
  - **parameters**:
75
75
  - **error**:
76
76
  - **type**: `unknown`
77
- - **description**: emitted when when `NuxtIsland` fails to fetch the new island.
77
+ - **description**: emitted when `NuxtIsland` fails to fetch the new island.
@@ -148,7 +148,7 @@ The `handler` function should be **side-effect free** to ensure predictable beha
148
148
  - `immediate`: when set to `false`, will prevent the request from firing immediately. (defaults to `true`)
149
149
  - `default`: a factory function to set the default value of the `data`, before the async function resolves - useful with the `lazy: true` or `immediate: false` option
150
150
  - `transform`: a function that can be used to alter `handler` function result after resolving
151
- - `getCachedData`: Provide a function which returns cached data. A `null` or `undefined` return value will trigger a fetch. By default, this is:
151
+ - `getCachedData`: Provide a function which returns cached data. An `undefined` return value will trigger a fetch. By default, this is:
152
152
  ```ts
153
153
  const getDefaultCachedData = (key, nuxtApp, ctx) => nuxtApp.isHydrating
154
154
  ? nuxtApp.payload.data[key]
@@ -161,6 +161,7 @@ type AsyncDataRequestContext = {
161
161
 
162
162
  type AsyncData<DataT, ErrorT> = {
163
163
  data: Ref<DataT | null>
164
+ pending: Ref<boolean>
164
165
  refresh: (opts?: AsyncDataExecuteOptions) => Promise<void>
165
166
  execute: (opts?: AsyncDataExecuteOptions) => Promise<void>
166
167
  clear: () => void
@@ -229,6 +230,7 @@ This only caches data when `experimental.payloadExtraction` in `nuxt.config` is
229
230
  | `execute` | `(opts?: AsyncDataExecuteOptions) => Promise<void>` | Alias for `refresh`. |
230
231
  | `error` | `Ref<ErrorT \| undefined>` | Error object if the data fetching failed. |
231
232
  | `status` | `Ref<'idle' \| 'pending' \| 'success' \| 'error'>` | Status of the data request. See below for possible values. |
233
+ | `pending` | `Ref<boolean>` | Boolean flag indicating whether the current request is in progress. |
232
234
  | `clear` | `() => void` | Resets `data` to `undefined` (or the value of `options.default()` if provided), `error` to `undefined`, set `status` to `idle`, and cancels any pending requests. |
233
235
 
234
236
  ### Status values
@@ -76,6 +76,7 @@ Returns the same `AsyncData` object as [`useFetch`](/docs/3.x/api/composables/us
76
76
  | `execute` | `(opts?: AsyncDataExecuteOptions) => Promise<void>` | Alias for `refresh`. |
77
77
  | `error` | `Ref<ErrorT \| undefined>` | Error object if the data fetching failed. |
78
78
  | `status` | `Ref<'idle' \| 'pending' \| 'success' \| 'error'>` | Status of the data request. |
79
+ | `pending` | `Ref<boolean>` | Boolean flag indicating whether the current request is in progress. |
79
80
  | `clear` | `() => void` | Resets `data` to `undefined`, `error` to `undefined`, sets `status` to `idle`, and cancels any pending requests. |
80
81
 
81
82
  :read-more{to="/docs/3.x/api/composables/use-fetch#return-values"}
@@ -32,7 +32,7 @@ The `build` command creates a `.output` directory with all your application, ser
32
32
  | `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`) |
33
33
  | `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level |
34
34
  | `--prerender` | | Build Nuxt and prerender static routes |
35
- | `--preset` | | Nitro server preset |
35
+ | `--preset=<preset>` | | Specify Nitro server preset. Available presets depend on Nitro (e.g. `node-server`, `vercel`, `netlify`, `static`) |
36
36
  | `--dotenv` | | Path to `.env` file to load, relative to the root directory |
37
37
  | `--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server) |
38
38
  | `-e, --extends=<layer-name>` | | Extend from a Nuxt layer |
@@ -302,7 +302,7 @@ function addPrerenderRoutes (routes: string | string[]): void
302
302
  Add imports to the server. It makes your imports available in Nitro without the need to import them manually.
303
303
 
304
304
  ::warning
305
- If you want to provide a utility that works in both server and client contexts and is usable in the [`shared/`](/docs/4.x/directory-structure/shared) directory, the function must be imported from the same source file for both [`addImports`](/docs/4.x/api/kit/autoimports#addimports) and `addServerImports` and should have identical signature. That source file should not import anything context-specific (i.e., Nitro context, Nuxt app context) or else it might cause errors during type-checking.
305
+ If you want to provide a utility that works in both server and client contexts and is usable in the [`shared/`](/docs/3.x/directory-structure/shared) directory, the function must be imported from the same source file for both [`addImports`](/docs/3.x/api/kit/autoimports#addimports) and `addServerImports` and should have identical signature. That source file should not import anything context-specific (i.e., Nitro context, Nuxt app context) or else it might cause errors during type-checking.
306
306
  ::
307
307
 
308
308
  ### Usage
@@ -426,10 +426,10 @@ export default defineEventHandler(() => {
426
426
  ## `addServerScanDir`
427
427
 
428
428
  Add directories to be scanned by Nitro. It will check for subdirectories, which will be registered
429
- just like the `~/server` folder is.
429
+ just like the `~~/server` folder is.
430
430
 
431
431
  ::note
432
- Only `~/server/api`, `~/server/routes`, `~/server/middleware`, and `~/server/utils` are scanned.
432
+ Only `~~/server/api`, `~~/server/routes`, `~~/server/middleware`, and `~~/server/utils` are scanned.
433
433
  ::
434
434
 
435
435
  ### Usage
@@ -27,7 +27,7 @@ Watch Vue School video about Auto-imports Nuxt Kit utilities.
27
27
  Add imports to the Nuxt application. It makes your imports available in the Nuxt app context without the need to import them manually.
28
28
 
29
29
  ::tip
30
- To add imports for the Nitro server context, refer to the [`addServerImports`](/docs/4.x/api/kit/nitro#addserverimports) function.
30
+ To add imports for the Nitro server context, refer to the [`addServerImports`](/docs/3.x/api/kit/nitro#addserverimports) function.
31
31
  ::
32
32
 
33
33
  ### Usage
@@ -41,7 +41,7 @@ We recommend taking a look at [how to report bugs](/docs/3.x/community/reporting
41
41
 
42
42
  ## "I need professional help"
43
43
 
44
- If the community couldn't provide the help you need in the time-frame you have, NuxtLabs offers professional support with the [Nuxt Experts](https://nuxt.com/enterprise/support).
44
+ If the community couldn't provide the help you need in the time-frame you have, NuxtLabs offers professional support with the [Nuxt Experts](https://nuxt.com/enterprise/agencies).
45
45
 
46
46
  The objective of the Nuxt Expert is to provide support to the Vue ecosystem, while also creating freelance opportunities for those contributing to open-source solutions, thus helping to maintain the sustainability of the ecosystem.
47
47
 
@@ -10,7 +10,7 @@ In a built Nuxt 3 application, there is no runtime Nuxt dependency. That means y
10
10
  ## Steps
11
11
 
12
12
  1. Remove the `render` key in your `nuxt.config`.
13
- 2. Any files in `~/server/api` and `~/server/middleware` will be automatically registered; you can remove them from your `serverMiddleware` array.
13
+ 2. Any files in `~~/server/api` and `~~/server/middleware` will be automatically registered; you can remove them from your `serverMiddleware` array.
14
14
  3. Update any other items in your `serverMiddleware` array to point to files or npm packages directly, rather than using inline functions.
15
15
 
16
16
  :read-more{to="/docs/3.x/directory-structure/server"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/docs",
3
- "version": "3.21.1",
3
+ "version": "3.21.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",