@nuxt/docs-nightly 4.2.0-29331656.27fe4652 → 4.2.0-29331807.eca36cfe
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.
|
@@ -28,7 +28,7 @@ Or follow the steps below to set up a new Nuxt project on your computer.
|
|
|
28
28
|
::note
|
|
29
29
|
::details
|
|
30
30
|
:summary[Additional notes for an optimal setup:]
|
|
31
|
-
- **Node.js**: Make sure to use an even numbered version (
|
|
31
|
+
- **Node.js**: Make sure to use an even numbered version (20, 22, etc.)
|
|
32
32
|
- **Nuxtr**: Install the community-developed [Nuxtr extension](https://marketplace.visualstudio.com/items?itemName=Nuxtr.nuxtr-vscode)
|
|
33
33
|
- **WSL**: If you are using Windows and experience slow HMR, you may want to try using [WSL (Windows Subsystem for Linux)](https://docs.microsoft.com/en-us/windows/wsl/install) which may solve some performance issues.
|
|
34
34
|
- **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.
|
|
@@ -102,6 +102,7 @@ The `handler` function should be **side-effect free** to ensure predictable beha
|
|
|
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
|
|
105
|
+
- `timeout` - a number in milliseconds to wait before timing out the request (defaults to `undefined`, which means no timeout)
|
|
105
106
|
|
|
106
107
|
::note
|
|
107
108
|
Under the hood, `lazy: false` uses `<Suspense>` to block the loading of the route before the data has been fetched. Consider using `lazy: true` and implementing a loading state instead for a snappier user experience.
|
|
@@ -170,12 +171,12 @@ If you have not fetched data on the server (for example, with `server: false`),
|
|
|
170
171
|
|
|
171
172
|
```ts [Signature]
|
|
172
173
|
export function useAsyncData<DataT, DataE> (
|
|
173
|
-
handler: (nuxtApp
|
|
174
|
+
handler: (nuxtApp: NuxtApp, options: { signal: AbortSignal }) => Promise<DataT>,
|
|
174
175
|
options?: AsyncDataOptions<DataT>
|
|
175
176
|
): AsyncData<DataT, DataE>
|
|
176
177
|
export function useAsyncData<DataT, DataE> (
|
|
177
178
|
key: MaybeRefOrGetter<string>,
|
|
178
|
-
handler: (nuxtApp
|
|
179
|
+
handler: (nuxtApp: NuxtApp, options: { signal: AbortSignal }) => Promise<DataT>,
|
|
179
180
|
options?: AsyncDataOptions<DataT>
|
|
180
181
|
): Promise<AsyncData<DataT, DataE>>
|
|
181
182
|
|
|
@@ -190,6 +191,7 @@ type AsyncDataOptions<DataT> = {
|
|
|
190
191
|
pick?: string[]
|
|
191
192
|
watch?: MultiWatchSources | false
|
|
192
193
|
getCachedData?: (key: string, nuxtApp: NuxtApp, ctx: AsyncDataRequestContext) => DataT | undefined
|
|
194
|
+
timeout?: number
|
|
193
195
|
}
|
|
194
196
|
|
|
195
197
|
type AsyncDataRequestContext = {
|
|
@@ -208,6 +210,8 @@ type AsyncData<DataT, ErrorT> = {
|
|
|
208
210
|
|
|
209
211
|
interface AsyncDataExecuteOptions {
|
|
210
212
|
dedupe?: 'cancel' | 'defer'
|
|
213
|
+
timeout?: number
|
|
214
|
+
signal?: AbortSignal
|
|
211
215
|
}
|
|
212
216
|
|
|
213
217
|
type AsyncDataRequestStatus = 'idle' | 'pending' | 'success' | 'error'
|
|
@@ -145,6 +145,7 @@ type UseFetchOptions<DataT> = {
|
|
|
145
145
|
getCachedData?: (key: string, nuxtApp: NuxtApp, ctx: AsyncDataRequestContext) => DataT | undefined
|
|
146
146
|
deep?: boolean
|
|
147
147
|
dedupe?: 'cancel' | 'defer'
|
|
148
|
+
timeout?: number
|
|
148
149
|
default?: () => DataT
|
|
149
150
|
transform?: (input: DataT) => DataT | Promise<DataT>
|
|
150
151
|
pick?: string[]
|
|
@@ -169,6 +170,8 @@ type AsyncData<DataT, ErrorT> = {
|
|
|
169
170
|
|
|
170
171
|
interface AsyncDataExecuteOptions {
|
|
171
172
|
dedupe?: 'cancel' | 'defer'
|
|
173
|
+
timeout?: number
|
|
174
|
+
signal?: AbortSignal
|
|
172
175
|
}
|
|
173
176
|
|
|
174
177
|
type AsyncDataRequestStatus = 'idle' | 'pending' | 'success' | 'error'
|
|
@@ -195,6 +198,7 @@ type AsyncDataRequestStatus = 'idle' | 'pending' | 'success' | 'error'
|
|
|
195
198
|
| `lazy` | `boolean` | `false` | If true, resolves after route loads (does not block navigation). |
|
|
196
199
|
| `immediate` | `boolean` | `true` | If false, prevents request from firing immediately. |
|
|
197
200
|
| `default` | `() => DataT` | - | Factory for default value of `data` before async resolves. |
|
|
201
|
+
| `timeout` | `number` | - | A number in milliseconds to wait before timing out the request (defaults to `undefined`, which means no timeout) |
|
|
198
202
|
| `transform` | `(input: DataT) => DataT \| Promise<DataT>` | - | Function to transform the result after resolving. |
|
|
199
203
|
| `getCachedData`| `(key, nuxtApp, ctx) => DataT \| undefined` | - | Function to return cached data. See below for default. |
|
|
200
204
|
| `pick` | `string[]` | - | Only pick specified keys from the result. |
|
|
@@ -113,6 +113,7 @@ function addComponent (options: AddComponentOptions): void
|
|
|
113
113
|
| ------------------ | ---------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
|
|
114
114
|
| `name` | `string` | `true` | Component name. |
|
|
115
115
|
| `filePath` | `string` | `true` | Path to the component. |
|
|
116
|
+
| `declarationPath` | `string` | `false` | Path to component's declaration file. It is used to generate components' [type templates](/docs/4.x/api/kit/templates#addtypetemplate); if not provided, `filePath` is used instead. |
|
|
116
117
|
| `pascalName` | `string` | `false` | Pascal case component name. If not provided, it will be generated from the component name. |
|
|
117
118
|
| `kebabName` | `string` | `false` | Kebab case component name. If not provided, it will be generated from the component name. |
|
|
118
119
|
| `export` | `string` | `false` | Specify named or default export. If not provided, it will be set to `'default'`. |
|