@nuxt/docs 4.0.0-alpha.2 → 4.0.0-alpha.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.
Files changed (30) hide show
  1. package/1.getting-started/10.data-fetching.md +1 -1
  2. package/1.getting-started/13.server.md +1 -1
  3. package/1.getting-started/15.prerendering.md +1 -1
  4. package/1.getting-started/17.testing.md +1 -1
  5. package/1.getting-started/18.upgrade.md +87 -0
  6. package/2.guide/1.concepts/4.server-engine.md +2 -2
  7. package/2.guide/1.concepts/8.typescript.md +32 -5
  8. package/2.guide/2.directory-structure/1.app/1.components.md +1 -1
  9. package/2.guide/2.directory-structure/1.server.md +2 -12
  10. package/2.guide/2.directory-structure/2.nuxtignore.md +6 -6
  11. package/2.guide/2.directory-structure/3.tsconfig.md +14 -3
  12. package/2.guide/3.going-further/1.experimental-features.md +1 -0
  13. package/2.guide/3.going-further/11.nightly-release-channel.md +2 -2
  14. package/2.guide/3.going-further/3.modules.md +0 -2
  15. package/3.api/1.components/4.nuxt-link.md +4 -0
  16. package/3.api/2.composables/on-prehydrate.md +21 -12
  17. package/3.api/2.composables/use-async-data.md +1 -1
  18. package/3.api/2.composables/use-cookie.md +62 -121
  19. package/3.api/2.composables/use-error.md +30 -7
  20. package/3.api/2.composables/use-fetch.md +70 -73
  21. package/3.api/2.composables/use-nuxt-app.md +1 -1
  22. package/3.api/3.utils/define-lazy-hydration-component.md +261 -0
  23. package/3.api/3.utils/define-nuxt-plugin.md +102 -0
  24. package/3.api/5.kit/13.logging.md +1 -1
  25. package/3.api/5.kit/6.context.md +1 -1
  26. package/3.api/6.advanced/1.hooks.md +8 -8
  27. package/3.api/6.nuxt-config.md +6 -5
  28. package/6.bridge/2.typescript.md +2 -0
  29. package/7.migration/2.configuration.md +13 -2
  30. package/package.json +1 -1
@@ -230,7 +230,7 @@ Read more about `useAsyncData`.
230
230
 
231
231
  - `data`: the result of the asynchronous function that is passed in.
232
232
  - `refresh`/`execute`: a function that can be used to refresh the data returned by the `handler` function.
233
- - `clear`: a function that can be used to set `data` to `undefined`, set `error` to `null`, set `status` to `idle`, and mark any currently pending requests as cancelled.
233
+ - `clear`: a function that can be used to set `data` to `undefined` (or the value of `options.default()` if provided), set `error` to `undefined`, set `status` to `idle`, and mark any currently pending requests as cancelled.
234
234
  - `error`: an error object if the data fetching failed.
235
235
  - `status`: a string indicating the status of the data request (`"idle"`, `"pending"`, `"success"`, `"error"`).
236
236
 
@@ -18,7 +18,7 @@ Using Nitro gives Nuxt superpowers:
18
18
  - Universal deployment on any provider (many zero-config)
19
19
  - Hybrid rendering
20
20
 
21
- Nitro is internally using [h3](https://github.com/unjs/h3), a minimal H(TTP) framework built for high performance and portability.
21
+ Nitro is internally using [h3](https://github.com/h3js/h3), a minimal H(TTP) framework built for high performance and portability.
22
22
 
23
23
  :video-accordion{title="Watch a video from Alexander Lichter to understand the responsibilities of Nuxt and Nitro in your application" videoId="DkvgJa-X31k"}
24
24
 
@@ -135,7 +135,7 @@ export default defineNuxtConfig({
135
135
  });
136
136
  ```
137
137
 
138
- ## Runtime prerender configuration
138
+ ## Runtime Prerender Configuration
139
139
 
140
140
  ### `prerenderRoutes`
141
141
 
@@ -444,7 +444,7 @@ If you prefer to use `@vue/test-utils` on its own for unit testing in Nuxt, and
444
444
 
445
445
  2. Create a `vitest.config.ts` with the following content:
446
446
 
447
- ```ts twoslash
447
+ ```ts
448
448
  import { defineConfig } from 'vitest/config'
449
449
  import vue from '@vitejs/plugin-vue'
450
450
 
@@ -980,6 +980,93 @@ const importName = genSafeVariableName
980
980
  You can automate this step by running `npx codemod@latest nuxt/4/template-compilation-changes`
981
981
  ::
982
982
 
983
+ ### TypeScript Configuration Changes
984
+
985
+ 🚦 **Impact Level**: Minimal
986
+
987
+ #### What Changed
988
+
989
+ Nuxt now generates separate TypeScript configurations for different contexts to provide better type-checking experiences:
990
+
991
+ 1. **New TypeScript configuration files**: Nuxt now generates additional TypeScript configurations:
992
+ * `.nuxt/tsconfig.app.json` - For your app code (Vue components, composables, etc.)
993
+ * `.nuxt/tsconfig.server.json` - For your server-side code (Nitro/server directory)
994
+ * `.nuxt/tsconfig.node.json` - For your build-time code (modules, `nuxt.config.ts`, etc.)
995
+ * `.nuxt/tsconfig.json` - Legacy configuration for backward compatibility
996
+
997
+ 2. **Backward compatibility**: Existing projects that extend `.nuxt/tsconfig.json` will continue to work as before.
998
+
999
+ 3. **Opt-in project references**: New projects or those wanting better type checking can adopt TypeScript's project references feature.
1000
+
1001
+ 4. **Context-specific type checking**: Each context now has appropriate compiler options and includes/excludes for its specific environment.
1002
+
1003
+ 5. **New `typescript.nodeTsConfig` option**: You can now customize the TypeScript configuration for Node.js build-time code.
1004
+
1005
+ #### Reasons for Change
1006
+
1007
+ This change provides several benefits:
1008
+
1009
+ 1. **Better type safety**: Each context (app, server, build-time) gets appropriate type checking with context-specific globals and APIs.
1010
+ 2. **Improved IDE experience**: Better IntelliSense and error reporting for different parts of your codebase.
1011
+ 3. **Cleaner separation**: Server code won't incorrectly suggest client-side APIs and vice versa.
1012
+ 4. **Performance**: TypeScript can more efficiently check code with properly scoped configurations.
1013
+
1014
+ For example, auto-imports are not available in your `nuxt.config.ts` (but previously this was not flagged by TypeScript). And while IDEs recognized the separate context hinted by `tsconfig.json` in your `server/` directory, this was not reflected in type-checking (requiring a separate step).
1015
+
1016
+ #### Migration Steps
1017
+
1018
+ **No migration is required** - existing projects will continue to work as before.
1019
+
1020
+ However, to take advantage of improved type checking, you can opt in to the new project references approach:
1021
+
1022
+ 1. **Update your root `tsconfig.json`** to use project references:
1023
+
1024
+ ```json
1025
+ {
1026
+ "files": [],
1027
+ "references": [
1028
+ { "path": "./.nuxt/tsconfig.app.json" },
1029
+ { "path": "./.nuxt/tsconfig.server.json" },
1030
+ { "path": "./.nuxt/tsconfig.node.json" }
1031
+ ]
1032
+ }
1033
+ ```
1034
+
1035
+ 2. **Remove any manual server `tsconfig.json`** files (like `server/tsconfig.json`) that extended `.nuxt/tsconfig.server.json`.
1036
+
1037
+ 3. **Update your type checking scripts** to use the build flag for project references:
1038
+
1039
+ ```diff
1040
+ - "typecheck": "nuxt prepare && vue-tsc --noEmit"
1041
+ + "typecheck": "nuxt prepare && vue-tsc -b --noEmit"
1042
+ ```
1043
+
1044
+ 4. **Configure Node.js TypeScript options** if needed:
1045
+ <!-- @case-police-ignore tsConfig -->
1046
+
1047
+ ```ts
1048
+ export default defineNuxtConfig({
1049
+ typescript: {
1050
+ // Customize app/server TypeScript config
1051
+ tsConfig: {
1052
+ compilerOptions: {
1053
+ strict: true
1054
+ }
1055
+ },
1056
+ // Customize build-time TypeScript config
1057
+ nodeTsConfig: {
1058
+ compilerOptions: {
1059
+ strict: true
1060
+ }
1061
+ }
1062
+ }
1063
+ })
1064
+ ```
1065
+
1066
+ 5. **Update any CI/build scripts** that run TypeScript checking to ensure they use the new project references approach.
1067
+
1068
+ The new configuration provides better type safety and IntelliSense for projects that opt in, while maintaining full backward compatibility for existing setups.
1069
+
983
1070
  ### Removal of Experimental Features
984
1071
 
985
1072
  🚦 **Impact Level**: Minimal
@@ -16,7 +16,7 @@ It is shipped with many features:
16
16
 
17
17
  ## API Layer
18
18
 
19
- Server [API endpoints](/docs/guide/directory-structure/server#api-routes) and [Middleware](/docs/guide/directory-structure/server#server-middleware) are added by Nitro that internally uses [h3](https://github.com/unjs/h3).
19
+ Server [API endpoints](/docs/guide/directory-structure/server#api-routes) and [Middleware](/docs/guide/directory-structure/server#server-middleware) are added by Nitro that internally uses [h3](https://github.com/h3js/h3).
20
20
 
21
21
  Key features include:
22
22
 
@@ -24,7 +24,7 @@ Key features include:
24
24
  - Handlers can return promises, which will be awaited (`res.end()` and `next()` are also supported)
25
25
  - Helper functions for body parsing, cookie handling, redirects, headers and more
26
26
 
27
- Check out [the h3 docs](https://github.com/unjs/h3) for more information.
27
+ Check out [the h3 docs](https://github.com/h3js/h3) for more information.
28
28
 
29
29
  ::read-more{to="/docs/guide/directory-structure/server#server-routes"}
30
30
  Learn more about the API layer in the `server/` directory.
@@ -55,7 +55,7 @@ This file contains the types of any modules you are using, as well as the key ty
55
55
 
56
56
  Some of the references in the file are to files that are only generated within your `buildDir` (`.nuxt`) and therefore for full typings, you will need to run `nuxt dev` or `nuxt build`.
57
57
 
58
- ### `.nuxt/tsconfig.json`
58
+ ### `.nuxt/tsconfig.app.json`
59
59
 
60
60
  This file contains the recommended basic TypeScript configuration for your project, including resolved aliases injected by Nuxt or modules you are using, so you can get full type support and path auto-complete for aliases like `~/file` or `#build/file`.
61
61
 
@@ -74,10 +74,37 @@ Nitro also [auto-generates types](/docs/guide/concepts/server-engine#typed-api-r
74
74
  ::
75
75
 
76
76
  ::note
77
- Keep in mind that all options extended from `./.nuxt/tsconfig.json` will be overwritten by the options defined in your `tsconfig.json`.
78
- Overwriting options such as `"compilerOptions.paths"` with your own configuration will lead TypeScript to not factor in the module resolutions from `./.nuxt/tsconfig.json`. This can lead to module resolutions such as `#imports` not being recognized.
79
- :br :br
80
- In case you need to extend options provided by `./.nuxt/tsconfig.json` further, you can use the [`alias` property](/docs/api/nuxt-config#alias) within your `nuxt.config`. Nuxt will pick them up and extend `./.nuxt/tsconfig.json` accordingly.
77
+ For backward compatibility, Nuxt still generates `./.nuxt/tsconfig.json`. However, we recommend using [TypeScript project references](/docs/guide/directory-structure/tsconfig) with the new configuration files (`.nuxt/tsconfig.app.json`, `.nuxt/tsconfig.server.json`, etc.) for better type safety and performance.
78
+
79
+ If you do extend from `./.nuxt/tsconfig.json`, keep in mind that all options will be overwritten by those defined in your `tsconfig.json`. Overwriting options such as `"compilerOptions.paths"` with your own configuration will lead TypeScript to not factor in the module resolutions, which can cause module resolutions such as `#imports` to not be recognized.
80
+
81
+ In case you need to extend options further, you can use the [`alias` property](/docs/api/nuxt-config#alias) within your `nuxt.config`. Nuxt will pick them up and extend the generated TypeScript configurations accordingly.
82
+ ::
83
+
84
+ ## Project References
85
+
86
+ Nuxt uses [TypeScript project references](https://www.typescriptlang.org/docs/handbook/project-references.html) to improve type-checking performance and provide better IDE support. This feature allows TypeScript to break up your codebase into smaller, more manageable pieces.
87
+
88
+ ### How Nuxt Uses Project References
89
+
90
+ When you run `nuxt dev` or `nuxt build`, Nuxt will generate multiple `tsconfig.json` files for different parts of your application.
91
+
92
+ - **`.nuxt/tsconfig.app.json`** - Configuration for your application code
93
+ - **`.nuxt/tsconfig.node.json`** - Configuration for your `nuxt.config` and modules
94
+ - **`.nuxt/tsconfig.server.json`** - Configuration for server-side code (when applicable)
95
+ - **`.nuxt/tsconfig.json`** - Legacy configuration for backward compatibility
96
+
97
+ Each of these files is configured to reference the appropriate dependencies and provide optimal type-checking for their specific context.
98
+
99
+ ### Benefits of Project References
100
+
101
+ - **Faster builds**: TypeScript can skip rebuilding unchanged projects
102
+ - **Better IDE performance**: Your IDE can provide faster IntelliSense and error checking
103
+ - **Isolated compilation**: Errors in one part of your application don't prevent compilation of other parts
104
+ - **Clearer dependency management**: Each project explicitly declares its dependencies
105
+
106
+ ::note
107
+ The project reference setup is handled automatically by Nuxt. You typically don't need to modify these configurations manually, but understanding how they work can help you troubleshoot type-checking issues.
81
108
  ::
82
109
 
83
110
  ## Strict Checks
@@ -187,7 +187,7 @@ Hydrates the component after a specified interaction (e.g., click, mouseover).
187
187
  </template>
188
188
  ```
189
189
 
190
- If you do not pass an event or list of events, it defaults to hydrating on `pointerenter` and `focus`.
190
+ If you do not pass an event or list of events, it defaults to hydrating on `pointerenter`, `click` and `focus`.
191
191
 
192
192
  ::note
193
193
  Under the hood, this uses Vue's built-in [`hydrateOnInteraction` strategy](https://vuejs.org/guide/components/async.html#hydrate-on-interaction).
@@ -101,7 +101,7 @@ export default defineNitroPlugin((nitroApp) => {
101
101
 
102
102
  ## Server Utilities
103
103
 
104
- Server routes are powered by [unjs/h3](https://github.com/unjs/h3) which comes with a handy set of helpers.
104
+ Server routes are powered by [h3js/h3](https://github.com/h3js/h3) which comes with a handy set of helpers.
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
 
@@ -136,16 +136,6 @@ export const defineWrappedResponseHandler = <T extends EventHandlerRequest, D> (
136
136
  This feature is available from Nuxt >= 3.5
137
137
  ::
138
138
 
139
- To improve clarity within your IDE between the auto-imports from 'nitro' and 'vue', you can add a `~/server/tsconfig.json` with the following content:
140
-
141
- ```json [server/tsconfig.json]
142
- {
143
- "extends": "../.nuxt/tsconfig.server.json"
144
- }
145
- ```
146
-
147
- Currently, these values won't be respected when type checking ([`nuxt typecheck`](/docs/api/commands/typecheck)), but you should get better type hints in your IDE.
148
-
149
139
  ## Recipes
150
140
 
151
141
  ### Route Parameters
@@ -448,7 +438,7 @@ export default fromNodeMiddleware((req, res) => {
448
438
  ```
449
439
 
450
440
  ::important
451
- Legacy support is possible using [unjs/h3](https://github.com/unjs/h3), but it is advised to avoid legacy handlers as much as you can.
441
+ Legacy support is possible using [h3js/h3](https://github.com/h3js/h3), but it is advised to avoid legacy handlers as much as you can.
452
442
  ::
453
443
 
454
444
  ```ts [server/middleware/legacy.ts]
@@ -17,18 +17,18 @@ You can also configure [`ignoreOptions`](/docs/api/nuxt-config#ignoreoptions), [
17
17
 
18
18
  ```bash [.nuxtignore]
19
19
  # ignore layout foo.vue
20
- layouts/foo.vue
20
+ app/layouts/foo.vue
21
21
  # ignore layout files whose name ends with -ignore.vue
22
- layouts/*-ignore.vue
22
+ app/layouts/*-ignore.vue
23
23
 
24
24
  # ignore page bar.vue
25
- pages/bar.vue
25
+ app/pages/bar.vue
26
26
  # ignore page inside ignore folder
27
- pages/ignore/*.vue
27
+ app/pages/ignore/*.vue
28
28
 
29
29
  # ignore route middleware files under foo folder except foo/bar.js
30
- middleware/foo/*.js
31
- !middleware/foo/bar.js
30
+ app/middleware/foo/*.js
31
+ !app/middleware/foo/bar.js
32
32
  ```
33
33
 
34
34
  ::read-more{icon="i-simple-icons-git" title="the git documentation" to="https://git-scm.com/docs/gitignore" target="_blank"}
@@ -1,17 +1,28 @@
1
1
  ---
2
2
  title: "tsconfig.json"
3
- description: "Nuxt generates a .nuxt/tsconfig.json file with sensible defaults and your aliases."
3
+ description: "Nuxt generates multiple TypeScript configuration files with sensible defaults and your aliases."
4
4
  head.title: "tsconfig.json"
5
5
  navigation.icon: i-lucide-file
6
6
  ---
7
7
 
8
- Nuxt [automatically generates](/docs/guide/concepts/typescript) a `.nuxt/tsconfig.json` file with the resolved aliases you are using in your Nuxt project, as well as with other sensible defaults.
8
+ Nuxt [automatically generates](/docs/guide/concepts/typescript) multiple TypeScript configuration files (`.nuxt/tsconfig.app.json`, `.nuxt/tsconfig.server.json`, `.nuxt/tsconfig.node.json`) with the resolved aliases you are using in your Nuxt project, as well as with other sensible defaults.
9
9
 
10
10
  You can benefit from this by creating a `tsconfig.json` in the root of your project with the following content:
11
11
 
12
12
  ```json [tsconfig.json]
13
13
  {
14
- "extends": "./.nuxt/tsconfig.json"
14
+ "files": [],
15
+ "references": [
16
+ {
17
+ "path": "./.nuxt/tsconfig.app.json"
18
+ },
19
+ {
20
+ "path": "./.nuxt/tsconfig.server.json"
21
+ },
22
+ {
23
+ "path": "./.nuxt/tsconfig.node.json"
24
+ }
25
+ ]
15
26
  }
16
27
  ```
17
28
 
@@ -386,6 +386,7 @@ package-lock.json
386
386
  yarn.lock
387
387
  pnpm-lock.yaml
388
388
  tsconfig.json
389
+ bun.lock
389
390
  bun.lockb
390
391
  ```
391
392
 
@@ -32,7 +32,7 @@ Update `nuxt` dependency inside `package.json`:
32
32
  }
33
33
  ```
34
34
 
35
- Remove lockfile (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, or `bun.lockb`) and reinstall dependencies.
35
+ Remove lockfile (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, `bun.lock` or `bun.lockb`) and reinstall dependencies.
36
36
 
37
37
  ## Opting Out
38
38
 
@@ -47,7 +47,7 @@ Update `nuxt` dependency inside `package.json`:
47
47
  }
48
48
  ```
49
49
 
50
- Remove lockfile (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, or `bun.lockb`) and reinstall dependencies.
50
+ Remove lockfile (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, `bun.lock` or `bun.lockb`) and reinstall dependencies.
51
51
 
52
52
  ## Using Nightly `@nuxt/cli`
53
53
 
@@ -230,8 +230,6 @@ Learn more about asset injection in [the recipes section](#recipes).
230
230
  Published modules cannot leverage auto-imports for assets within their runtime directory. Instead, they have to import them explicitly from `#imports` or alike.
231
231
  :br :br
232
232
  Indeed, auto-imports are not enabled for files within `node_modules` (the location where a published module will eventually live) for performance reasons.
233
- :br :br
234
- If you are using the module starter, auto-imports will not be enabled in your playground either.
235
233
  ::
236
234
 
237
235
  ### Tooling
@@ -51,6 +51,10 @@ In this example, we pass the `id` param to link to the route `~/pages/posts/[id]
51
51
  Check out the Pages panel in Nuxt DevTools to see the route name and the params it might take.
52
52
  ::
53
53
 
54
+ ::tip
55
+ When you pass an object into the `to` prop, `<NuxtLink>` will inherit Vue Router’s handling of query parameters. Keys and values will be automatically encoded, so you don’t need to call `encodeURI` or `encodeURIComponent` manually.
56
+ ::
57
+
54
58
  ### Handling Static File and Cross-App Links
55
59
 
56
60
  By default, `<NuxtLink>` uses Vue Router's client side navigation for relative route. When linking to static files in the `/public` directory or to another application hosted on the same domain, it might result in unexpected 404 errors because they are not part of the client routes. In such cases, you can use the `external` prop with `<NuxtLink>` to bypass Vue Router's internal routing mechanism.
@@ -12,23 +12,33 @@ links:
12
12
  This composable is available in Nuxt v3.12+.
13
13
  ::
14
14
 
15
- `onPrehydrate` is a composable lifecycle hook that allows you to run a callback on the client immediately before
16
- Nuxt hydrates the page.
17
-
15
+ `onPrehydrate` is a composable lifecycle hook that allows you to run a callback on the client immediately before Nuxt hydrates the page.
18
16
  ::note
19
17
  This is an advanced utility and should be used with care. For example, [`nuxt-time`](https://github.com/danielroe/nuxt-time/pull/251) and [`@nuxtjs/color-mode`](https://github.com/nuxt-modules/color-mode/blob/main/src/script.js) manipulate the DOM to avoid hydration mismatches.
20
18
  ::
21
19
 
22
20
  ## Usage
23
21
 
24
- `onPrehydrate` can be called directly in the setup function of a Vue component (for example, in `<script setup>`), or in a plugin.
25
- It will only have an effect when it is called on the server, and it will not be included in your client build.
22
+ Call `onPrehydrate` in the setup function of a Vue component (e.g., in `<script setup>`) or in a plugin. It only has an effect when called on the server and will not be included in your client build.
23
+
24
+ ## Type
25
+
26
+ ```ts [Signature]
27
+ export function onPrehydrate(callback: (el: HTMLElement) => void): void
28
+ export function onPrehydrate(callback: string | ((el: HTMLElement) => void), key?: string): undefined | string
29
+ ```
26
30
 
27
31
  ## Parameters
28
32
 
29
- - `callback`: A function that will be stringified and inlined in the HTML. It should not have any external
30
- dependencies (such as auto-imports) or refer to variables defined outside the callback. The callback will run
31
- before Nuxt runtime initializes so it should not rely on the Nuxt or Vue context.
33
+ | Parameter | Type | Required | Description |
34
+ | ---- | --- | --- | --- |
35
+ | `callback` | `((el: HTMLElement) => void) \| string` | Yes | A function (or stringified function) to run before Nuxt hydrates. It will be stringified and inlined in the HTML. Should not have external dependencies or reference variables outside the callback. Runs before Nuxt runtime initializes, so it should not rely on Nuxt or Vue context. |
36
+ | `key` | `string` | No | (Advanced) A unique key to identify the prehydrate script, useful for advanced scenarios like multiple root nodes. |
37
+
38
+ ## Return Values
39
+
40
+ - Returns `undefined` when called with only a callback function.
41
+ - Returns a string (the prehydrate id) when called with a callback and a key, which can be used to set or access the `data-prehydrate-id` attribute for advanced use cases.
32
42
 
33
43
  ## Example
34
44
 
@@ -36,19 +46,18 @@ before Nuxt runtime initializes so it should not rely on the Nuxt or Vue context
36
46
  <script setup lang="ts">
37
47
  declare const window: Window
38
48
  // ---cut---
39
- // onPrehydrate is guaranteed to run before Nuxt hydrates
49
+ // Run code before Nuxt hydrates
40
50
  onPrehydrate(() => {
41
51
  console.log(window)
42
52
  })
43
53
 
44
- // As long as it only has one root node, you can access the element
54
+ // Access the root element
45
55
  onPrehydrate((el) => {
46
56
  console.log(el.outerHTML)
47
57
  // <div data-v-inspector="app.vue:15:3" data-prehydrate-id=":b3qlvSiBeH:"> Hi there </div>
48
58
  })
49
59
 
50
- // For _very_ advanced use cases (such as not having a single root node) you
51
- // can access/set `data-prehydrate-id` yourself
60
+ // Advanced: access/set `data-prehydrate-id` yourself
52
61
  const prehydrateId = onPrehydrate((el) => {})
53
62
  </script>
54
63
 
@@ -154,7 +154,7 @@ const { data: users2 } = useAsyncData('users', () => $fetch('/api/users'), { imm
154
154
  - `pending`: the request is in progress
155
155
  - `success`: the request has completed successfully
156
156
  - `error`: the request has failed
157
- - `clear`: a function which will set `data` to `undefined`, set `error` to `null`, set `status` to `'idle'`, and mark any currently pending requests as cancelled.
157
+ - `clear`: a function that can be used to set `data` to `undefined` (or the value of `options.default()` if provided), set `error` to `undefined`, set `status` to `idle`, and mark any currently pending requests as cancelled.
158
158
 
159
159
  By default, Nuxt waits until a `refresh` is finished before it can be executed again.
160
160