@nuxt/docs-nightly 4.2.0-29331232.6f9cb0d2 → 4.2.0-29331656.27fe4652
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 (18, 20, 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,7 +102,6 @@ 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)
|
|
106
105
|
|
|
107
106
|
::note
|
|
108
107
|
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.
|
|
@@ -171,12 +170,12 @@ If you have not fetched data on the server (for example, with `server: false`),
|
|
|
171
170
|
|
|
172
171
|
```ts [Signature]
|
|
173
172
|
export function useAsyncData<DataT, DataE> (
|
|
174
|
-
handler: (nuxtApp
|
|
173
|
+
handler: (nuxtApp?: NuxtApp) => Promise<DataT>,
|
|
175
174
|
options?: AsyncDataOptions<DataT>
|
|
176
175
|
): AsyncData<DataT, DataE>
|
|
177
176
|
export function useAsyncData<DataT, DataE> (
|
|
178
177
|
key: MaybeRefOrGetter<string>,
|
|
179
|
-
handler: (nuxtApp
|
|
178
|
+
handler: (nuxtApp?: NuxtApp) => Promise<DataT>,
|
|
180
179
|
options?: AsyncDataOptions<DataT>
|
|
181
180
|
): Promise<AsyncData<DataT, DataE>>
|
|
182
181
|
|
|
@@ -191,7 +190,6 @@ type AsyncDataOptions<DataT> = {
|
|
|
191
190
|
pick?: string[]
|
|
192
191
|
watch?: MultiWatchSources | false
|
|
193
192
|
getCachedData?: (key: string, nuxtApp: NuxtApp, ctx: AsyncDataRequestContext) => DataT | undefined
|
|
194
|
-
timeout?: number
|
|
195
193
|
}
|
|
196
194
|
|
|
197
195
|
type AsyncDataRequestContext = {
|
|
@@ -210,8 +208,6 @@ type AsyncData<DataT, ErrorT> = {
|
|
|
210
208
|
|
|
211
209
|
interface AsyncDataExecuteOptions {
|
|
212
210
|
dedupe?: 'cancel' | 'defer'
|
|
213
|
-
timeout?: number
|
|
214
|
-
signal?: AbortSignal
|
|
215
211
|
}
|
|
216
212
|
|
|
217
213
|
type AsyncDataRequestStatus = 'idle' | 'pending' | 'success' | 'error'
|
|
@@ -145,7 +145,6 @@ 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
|
|
149
148
|
default?: () => DataT
|
|
150
149
|
transform?: (input: DataT) => DataT | Promise<DataT>
|
|
151
150
|
pick?: string[]
|
|
@@ -170,8 +169,6 @@ type AsyncData<DataT, ErrorT> = {
|
|
|
170
169
|
|
|
171
170
|
interface AsyncDataExecuteOptions {
|
|
172
171
|
dedupe?: 'cancel' | 'defer'
|
|
173
|
-
timeout?: number
|
|
174
|
-
signal?: AbortSignal
|
|
175
172
|
}
|
|
176
173
|
|
|
177
174
|
type AsyncDataRequestStatus = 'idle' | 'pending' | 'success' | 'error'
|
|
@@ -198,7 +195,6 @@ type AsyncDataRequestStatus = 'idle' | 'pending' | 'success' | 'error'
|
|
|
198
195
|
| `lazy` | `boolean` | `false` | If true, resolves after route loads (does not block navigation). |
|
|
199
196
|
| `immediate` | `boolean` | `true` | If false, prevents request from firing immediately. |
|
|
200
197
|
| `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) |
|
|
202
198
|
| `transform` | `(input: DataT) => DataT \| Promise<DataT>` | - | Function to transform the result after resolving. |
|
|
203
199
|
| `getCachedData`| `(key, nuxtApp, ctx) => DataT \| undefined` | - | Function to return cached data. See below for default. |
|
|
204
200
|
| `pick` | `string[]` | - | Only pick specified keys from the result. |
|
|
@@ -113,7 +113,6 @@ 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. |
|
|
117
116
|
| `pascalName` | `string` | `false` | Pascal case component name. If not provided, it will be generated from the component name. |
|
|
118
117
|
| `kebabName` | `string` | `false` | Kebab case component name. If not provided, it will be generated from the component name. |
|
|
119
118
|
| `export` | `string` | `false` | Specify named or default export. If not provided, it will be set to `'default'`. |
|