@nuxt/docs-nightly 5.0.0-29837649.bdf0b4f2 → 5.0.0-29837794.25b87beb
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/15.prerendering.md +1 -1
- package/3.guide/4.modules/9.server-compatibility.md +6 -3
- package/3.guide/5.recipes/1.custom-routing.md +1 -1
- package/3.guide/6.going-further/1.experimental-features.md +10 -20
- package/3.guide/6.going-further/1.features.md +2 -16
- package/3.guide/6.going-further/5.server-imports.md +48 -25
- package/4.api/2.composables/use-server-seo-meta.md +1 -1
- package/4.api/3.utils/clear-nuxt-state.md +1 -1
- package/4.api/6.advanced/2.import-meta.md +1 -1
- package/package.json +1 -1
|
@@ -158,7 +158,7 @@ You can control this behavior with the [`experimental.payloadExtraction`](/docs/
|
|
|
158
158
|
- `true` - The payload is extracted to a separate `_payload.json` file for both the initial render and client-side navigation. The HTML is smaller and the payload file can be cached by a CDN, at the cost of one extra request on first load.
|
|
159
159
|
- `false` - Payload extraction is disabled. The payload is always inlined in the HTML and no `_payload.json` files are generated.
|
|
160
160
|
|
|
161
|
-
The default is `
|
|
161
|
+
The default is `'client'`. It is forced to `false` when `ssr: false` is set.
|
|
162
162
|
|
|
163
163
|
```ts twoslash [nuxt.config.ts]
|
|
164
164
|
export default defineNuxtConfig({
|
|
@@ -145,17 +145,20 @@ If we can't tell, code will be treated as `nitro2`.
|
|
|
145
145
|
|
|
146
146
|
## Nitro-specific Code
|
|
147
147
|
|
|
148
|
-
`nuxt/server` covers request and response work: handlers, errors, query and body reading, headers, cookies, redirects, route rules and
|
|
148
|
+
`nuxt/server` covers request and response work: handlers, errors, router params, query and body reading and validation, headers, CORS, cookies, sessions, redirects, route rules, runtime config and app config. But Nitro covers a lot more, so if you need any of these areas, you might need to stay on Nitro's own imports inside a `nitro2` or `nitro3` file.
|
|
149
149
|
|
|
150
150
|
Use the specifiers of the version the file is for. A file that imports `nitro/*` is read as Nitro 3 code, so a `nitro2` file must import `h3` and `nitropack/*` instead:
|
|
151
151
|
|
|
152
152
|
| Area | In a `nitro3` file | In a `nitro2` file |
|
|
153
153
|
| --- | --- | --- |
|
|
154
154
|
| Storage: `useStorage()` and its driver configuration | `nitro/storage` | `nitropack/runtime` |
|
|
155
|
-
| Sessions: `useSession`, `getSession`, `updateSession`, `clearSession` | `nitro/h3` | `h3` |
|
|
156
155
|
| Caching: `defineCachedHandler()`, `defineCachedFunction()` | `nitro/cache` | `nitropack/runtime` |
|
|
156
|
+
| Server plugins | `definePlugin()` from `nitro` | `defineNitroPlugin()` from `nitropack/runtime` |
|
|
157
|
+
| Runtime hooks, including `render:html` | `useNitroHooks()` from `nitro/app` | `useNitroApp().hooks` from `nitropack/runtime` |
|
|
158
|
+
| App-relative fetch | `serverFetch()` from `nitro` | `useNitroApp().localFetch` from `nitropack/runtime` |
|
|
159
|
+
| Lazy handlers: `lazyEventHandler()` | `nitro/h3` | `h3` |
|
|
157
160
|
|
|
158
|
-
|
|
161
|
+
Tasks are also not supported by `nuxt/server`.
|
|
159
162
|
|
|
160
163
|
::read-more{to="/docs/guide/going-further/server-imports#reaching-past-the-surface"}
|
|
161
164
|
See which h3 helpers work with the portable event, and which need Nitro-specific utilities.
|
|
@@ -138,7 +138,7 @@ export default defineNuxtConfig({
|
|
|
138
138
|
```
|
|
139
139
|
|
|
140
140
|
::note
|
|
141
|
-
|
|
141
|
+
Routing is case-sensitive by default to match Nitro. Set `router.options.sensitive` to `false` to opt out.
|
|
142
142
|
::
|
|
143
143
|
|
|
144
144
|
### Hash Mode (SPA)
|
|
@@ -193,23 +193,14 @@ export default defineNuxtConfig({
|
|
|
193
193
|
## parseErrorData
|
|
194
194
|
|
|
195
195
|
::warning
|
|
196
|
-
This option is deprecated and will be removed.
|
|
196
|
+
This option is deprecated and will be removed. It is forced on and setting it is ignored.
|
|
197
197
|
::
|
|
198
198
|
|
|
199
199
|
Whether to parse `error.data` when rendering a server error page.
|
|
200
200
|
|
|
201
201
|
It existed because the error was previously passed to the error page as individual query parameters, which stringified `error.data` and meant it had to be parsed back. Setting it to `false` opted out of that parsing and left you with the string.
|
|
202
202
|
|
|
203
|
-
The error is now JSON-encoded as a whole, so `error.data` arrives with its original shape and is never stringified.
|
|
204
|
-
|
|
205
|
-
```ts twoslash [nuxt.config.ts]
|
|
206
|
-
export default defineNuxtConfig({
|
|
207
|
-
future: { compatibilityVersion: 4 },
|
|
208
|
-
experimental: {
|
|
209
|
-
parseErrorData: false,
|
|
210
|
-
},
|
|
211
|
-
})
|
|
212
|
-
```
|
|
203
|
+
The error is now JSON-encoded as a whole, so `error.data` arrives with its original shape and is never stringified.
|
|
213
204
|
|
|
214
205
|
## payloadExtraction
|
|
215
206
|
|
|
@@ -219,7 +210,7 @@ Controls how payload data is delivered for prerendered and cached (ISR/SWR) page
|
|
|
219
210
|
- `true` - Payload is extracted to a separate `_payload.json` file for both the initial server render and client-side navigation.
|
|
220
211
|
- `false` - Payload extraction is disabled entirely. Payload is always inlined in HTML and no `_payload.json` files are generated.
|
|
221
212
|
|
|
222
|
-
The default is `
|
|
213
|
+
The default is `'client'`. It is forced to `false` when `ssr: false` is set.
|
|
223
214
|
|
|
224
215
|
```ts twoslash [nuxt.config.ts]
|
|
225
216
|
export default defineNuxtConfig({
|
|
@@ -243,12 +234,12 @@ When enabled, `.client.vue` components and `createClientOnly()` wrappers render
|
|
|
243
234
|
Enabling this means attributes (`class`, `style`, etc.) passed to `.client.vue` components will not appear in the SSR HTML. If you need styled placeholders to prevent layout shift, use `<ClientOnly>` with a `#fallback` slot instead.
|
|
244
235
|
::
|
|
245
236
|
|
|
246
|
-
This flag is enabled
|
|
237
|
+
This flag is enabled by default, but you can disable it:
|
|
247
238
|
|
|
248
239
|
```ts twoslash [nuxt.config.ts]
|
|
249
240
|
export default defineNuxtConfig({
|
|
250
241
|
experimental: {
|
|
251
|
-
clientNodePlaceholder:
|
|
242
|
+
clientNodePlaceholder: false,
|
|
252
243
|
},
|
|
253
244
|
})
|
|
254
245
|
```
|
|
@@ -478,8 +469,7 @@ You can also set this to `chokidar` to watch all files in your source directory.
|
|
|
478
469
|
|
|
479
470
|
Set to `'builder'` to reuse the active builder's own file watcher (for example,
|
|
480
471
|
Vite's `server.watcher`) instead of starting a second one. This reduces the
|
|
481
|
-
number of file watchers active in dev mode and
|
|
482
|
-
`future.compatibilityVersion` is `5`. If the active builder does not implement
|
|
472
|
+
number of file watchers active in dev mode and is the default. If the active builder does not implement
|
|
483
473
|
its own watcher (currently webpack and rspack), Nuxt logs a warning and falls
|
|
484
474
|
back to its default selection.
|
|
485
475
|
|
|
@@ -656,7 +646,7 @@ This allows modules to access additional metadata from the page metadata in the
|
|
|
656
646
|
|
|
657
647
|
## extractSerializablePageMeta
|
|
658
648
|
|
|
659
|
-
Enabled by default
|
|
649
|
+
Enabled by default.
|
|
660
650
|
|
|
661
651
|
By default, Nuxt only reads a fixed list of `definePageMeta()` keys at build time (plus anything in `extraPageMetaExtractionKeys`); everything else is resolved at runtime from a separate module generated per page. With this option, Nuxt writes every JSON-serializable property straight into the generated route record instead.
|
|
662
652
|
|
|
@@ -705,7 +695,7 @@ Transform top-level `await navigateTo()` calls in `<script setup>` into an early
|
|
|
705
695
|
|
|
706
696
|
Without this flag, code after `await navigateTo()` continues to run, which can result in later code (including subsequent `navigateTo` calls) overriding the redirect or attempting to render a page with missing data. With this flag enabled, a successful navigation stops execution of the rest of your setup code and the component renders a placeholder comment while the navigation proceeds.
|
|
707
697
|
|
|
708
|
-
This flag is enabled by default
|
|
698
|
+
This flag is enabled by default, but you can disable it:
|
|
709
699
|
|
|
710
700
|
```ts twoslash [nuxt.config.ts]
|
|
711
701
|
export default defineNuxtConfig({
|
|
@@ -773,7 +763,7 @@ By default, Vue assigns component names based on the filename. For example, `pag
|
|
|
773
763
|
|
|
774
764
|
With `normalizePageNames` enabled, page components are named after their route (e.g. `foo` and `bar`), so you can use `<KeepAlive>` with `include`/`exclude` without manually adding `defineOptions({ name: '...' })` to each page.
|
|
775
765
|
|
|
776
|
-
This flag is enabled
|
|
766
|
+
This flag is enabled by default, but you can disable this feature:
|
|
777
767
|
|
|
778
768
|
```ts twoslash [nuxt.config.ts]
|
|
779
769
|
export default defineNuxtConfig({
|
|
@@ -992,7 +982,7 @@ export default defineNuxtConfig({
|
|
|
992
982
|
})
|
|
993
983
|
```
|
|
994
984
|
|
|
995
|
-
The `useState.resetOnClear` option controls whether [`clearNuxtState`](/docs/api/utils/clear-nuxt-state) resets state to its initial value (provided by the `init` function of [`useState`](/docs/api/composables/use-state)) instead of setting it to `undefined`. This defaults to `true
|
|
985
|
+
The `useState.resetOnClear` option controls whether [`clearNuxtState`](/docs/api/utils/clear-nuxt-state) resets state to its initial value (provided by the `init` function of [`useState`](/docs/api/composables/use-state)) instead of setting it to `undefined`. This defaults to `true`.
|
|
996
986
|
|
|
997
987
|
## purgeCachedData
|
|
998
988
|
|
|
@@ -95,22 +95,8 @@ See the mostly-static site recipe for combining `noScripts` with prerendering, i
|
|
|
95
95
|
|
|
96
96
|
There is also a `future` namespace for early opting-in to new features that will become default in a future (possibly major) version of the framework.
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
This enables early access to Nuxt features or flags.
|
|
101
|
-
|
|
102
|
-
On Nuxt 5 it resolves to `5`, and the defaults described in the upgrade guide apply. Individual changes are configured through the options named there rather than through this one.
|
|
103
|
-
|
|
104
|
-
```ts
|
|
105
|
-
export default defineNuxtConfig({
|
|
106
|
-
future: {
|
|
107
|
-
compatibilityVersion: 5,
|
|
108
|
-
},
|
|
109
|
-
})
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
::read-more{to="/docs/getting-started/upgrade#migrating-to-nuxt-5"}
|
|
113
|
-
Learn more about migrating to Nuxt 5.
|
|
98
|
+
::note
|
|
99
|
+
`future.compatibilityVersion` always resolves to `5` in Nuxt 5. To opt into Nuxt 5 behaviour on Nuxt 4, see the [Nuxt 4 documentation](https://nuxt.com/docs/4.x/getting-started/upgrade#testing-nuxt-5).
|
|
114
100
|
::
|
|
115
101
|
|
|
116
102
|
### multiApp
|
|
@@ -36,21 +36,24 @@ This code can run under `@nuxt/nitro-server` and under `@nuxt/vite-server`, and
|
|
|
36
36
|
| `createError`, `isNuxtError` | Construct and recognise an HTTP error. |
|
|
37
37
|
| `getRequestURL` | The URL of the request. |
|
|
38
38
|
| `getRequestHeader`, `getRequestHeaders` | Read request headers. |
|
|
39
|
-
| `
|
|
40
|
-
| `
|
|
39
|
+
| `getRouterParam`, `getRouterParams` | Read the dynamic segments matched for the request. |
|
|
40
|
+
| `getRequestIP` | The client IP address, with [forwarded headers trusted on request](#client-ip). |
|
|
41
|
+
| `getQuery`, `getValidatedQuery` | Read the query string, optionally [validated](#validation). |
|
|
42
|
+
| `readBody`, `readValidatedBody` | Read and parse the request body, optionally [validated](#validation). |
|
|
41
43
|
| `getCookie`, `setCookie`, `deleteCookie` | Read and write cookies. |
|
|
42
44
|
| `setResponseStatus` | Set the response status and reason phrase. |
|
|
43
|
-
| `
|
|
45
|
+
| `handleCors` | Apply [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS) headers and answer preflight requests. |
|
|
44
46
|
| `sendRedirect` | Redirect the request. |
|
|
45
47
|
| `useSession`, `getSession`, `updateSession`, `clearSession` | Read and write a [sealed session cookie](#sessions). |
|
|
46
48
|
| `deriveSecret` | A purpose-specific secret [derived from `appSecret`](#deriving-secrets). |
|
|
47
49
|
| `getRouteRules` | The [route rules](/docs/guide/concepts/rendering#route-rules) matched for the request. |
|
|
48
50
|
| `useRuntimeConfig` | The server's [runtime configuration](/docs/guide/going-further/runtime-config). |
|
|
51
|
+
| `useAppConfig` | The [app config](/docs/directory-structure/app/app-config), as a copy per request when passed the event. |
|
|
49
52
|
| `toNuxtRequestEvent` | The event in the shape the server runtime provides. |
|
|
50
53
|
|
|
51
|
-
Types are exported alongside the utilities: `RequestEvent`, `RequestEventContext`, `NuxtRequestEvent`, `EventHandler`, `AppRouteRules`, `ServerRoutes`, `NuxtError`, `NuxtErrorDetails`, `NuxtErrorJSON`, `NuxtErrorLike`, `Session`, `SessionConfig`, `SessionData`, `SessionEvent`, `SessionManager`, `SessionPassword` and `SessionUpdate`.
|
|
54
|
+
Types are exported alongside the utilities: `RequestEvent`, `RequestEventContext`, `NuxtRequestEvent`, `EventHandler`, `AppRouteRules`, `ServerRoutes`, `CorsOptions`, `ValidateResult`, `NuxtError`, `NuxtErrorDetails`, `NuxtErrorJSON`, `NuxtErrorLike`, `Session`, `SessionConfig`, `SessionData`, `SessionEvent`, `SessionManager`, `SessionPassword` and `SessionUpdate`.
|
|
52
55
|
|
|
53
|
-
These names are [auto-imported](/docs/directory-structure/server) in server code, so the import statement above is optional. Writing it keeps the file working in a project with server auto-imports off, and is what a module should do.
|
|
56
|
+
These names, except `useAppConfig`, are [auto-imported](/docs/directory-structure/server) in server code, so the import statement above is optional. Writing it keeps the file working in a project with server auto-imports off, and is what a module should do.
|
|
54
57
|
|
|
55
58
|
::tip
|
|
56
59
|
`defineEventHandler` preserves your handler's return type, which is what types [`$fetch` and `useFetch`](/docs/getting-started/data-fetching) calls to the route. Annotate the value you return rather than the handler.
|
|
@@ -69,6 +72,8 @@ interface RequestEvent {
|
|
|
69
72
|
}
|
|
70
73
|
```
|
|
71
74
|
|
|
75
|
+
To set, read, append or remove a response header, use `event.res.headers` directly: it is a standard `Headers` object.
|
|
76
|
+
|
|
72
77
|
Nitro adds more on top, such as `event.node`, `event.runtime` and `event.waitUntil()`, but these four core properties work in all runtimes, and need no helpers:
|
|
73
78
|
|
|
74
79
|
```ts [server/api/echo.post.ts]
|
|
@@ -80,6 +85,28 @@ export default defineEventHandler(async (event) => {
|
|
|
80
85
|
|
|
81
86
|
`NuxtRequestEvent` is the same request in the shape the configured builder provides, which is h3's `H3Event` under `@nuxt/nitro-server`. You can get a type-safe version of the event for the server builder you're using by calling `toNuxtRequestEvent(event)`.
|
|
82
87
|
|
|
88
|
+
## Validation
|
|
89
|
+
|
|
90
|
+
`readValidatedBody` and `getValidatedQuery` take any [Standard Schema](https://standardschema.dev) (Zod, Valibot, ArkType and others), or a function that returns the validated value, `true` to accept the input or `false` to reject it.
|
|
91
|
+
|
|
92
|
+
```ts [server/api/users.post.ts]
|
|
93
|
+
import { defineEventHandler, readValidatedBody } from 'nuxt/server'
|
|
94
|
+
import { z } from 'zod'
|
|
95
|
+
|
|
96
|
+
export default defineEventHandler(async (event) => {
|
|
97
|
+
const user = await readValidatedBody(event, z.object({ name: z.string() }))
|
|
98
|
+
return { created: user.name }
|
|
99
|
+
})
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Invalid input is rejected with a `400` whose `data.issues` lists what failed. Pass `onError` to reject it with a different error.
|
|
103
|
+
|
|
104
|
+
## Client IP
|
|
105
|
+
|
|
106
|
+
`getRequestIP(event)` returns the address the server runtime reports for the connection, or `undefined` if it reports none. No forwarded header is trusted by default, because a client can send any value in one.
|
|
107
|
+
|
|
108
|
+
Behind a proxy you control, pass `{ xForwardedFor: true }` to read the first entry of `X-Forwarded-For` instead. Only do this when the proxy overwrites the header: a proxy that appends to it leaves a client-sent value first.
|
|
109
|
+
|
|
83
110
|
## Sessions
|
|
84
111
|
|
|
85
112
|
`useSession` reads the session for the request, sealing a new one into a cookie when there is none to read. The data is sealed with [iron](https://github.com/brc-dd/iron-webcrypto), so it lives in the cookie rather than in server storage, and the cookie defaults to `httpOnly`, `secure`, `sameSite: 'lax'` and `path: '/'`.
|
|
@@ -126,52 +153,48 @@ Most of those helpers take the event as it is:
|
|
|
126
153
|
|
|
127
154
|
```ts [server/api/upload.post.ts]
|
|
128
155
|
import { defineEventHandler } from 'nuxt/server'
|
|
129
|
-
import {
|
|
156
|
+
import { readMultipartFormData } from 'nitro/h3'
|
|
130
157
|
|
|
131
158
|
export default defineEventHandler(async (event) => {
|
|
132
|
-
const
|
|
133
|
-
return { received:
|
|
159
|
+
const parts = await readMultipartFormData(event)
|
|
160
|
+
return { received: parts?.length ?? 0 }
|
|
134
161
|
})
|
|
135
162
|
```
|
|
136
163
|
|
|
137
|
-
That works for any h3 helper that only reads the request
|
|
164
|
+
That works for any h3 helper that only reads the request, such as `readRawBody`, `readFormData`, `readMultipartFormData` and `assertMethod`.
|
|
138
165
|
|
|
139
166
|
A helper that needs the runtime's own event gets it from `toNuxtRequestEvent`:
|
|
140
167
|
|
|
141
|
-
```ts [server/api/
|
|
168
|
+
```ts [server/api/proxy.ts]
|
|
142
169
|
import { defineEventHandler, toNuxtRequestEvent } from 'nuxt/server'
|
|
143
|
-
import {
|
|
170
|
+
import { proxyRequest } from 'nitro/h3'
|
|
144
171
|
|
|
145
|
-
export default defineEventHandler((event)
|
|
146
|
-
handleCors(toNuxtRequestEvent(event), { origin: '*' })
|
|
147
|
-
return { ok: true }
|
|
148
|
-
})
|
|
172
|
+
export default defineEventHandler(event => proxyRequest(toNuxtRequestEvent(event), 'https://example.com'))
|
|
149
173
|
```
|
|
150
174
|
|
|
151
|
-
Helpers that need you to call `toNuxtRequestEvent` are
|
|
175
|
+
Helpers that need you to call `toNuxtRequestEvent` are `proxy`, `proxyRequest`, `fetchWithEvent`, `writeEarlyHints`, and reading `event.node`, `event.waitUntil()` or `event.runtime`. The helper works on every builder, and a cast to `NuxtRequestEvent` is safe even if the runtime's event is web-shaped, as it is under `@nuxt/nitro-server`.
|
|
152
176
|
|
|
153
177
|
Nitro's own APIs mostly take no event at all: `getRouteRules(method, pathname)`, `serverFetch()`, `defineCachedHandler()`, `useStorage()`, `useDatabase()` and tasks.
|
|
154
178
|
|
|
155
179
|
::tip
|
|
156
180
|
If you find you are writing Nitro-specific code, you may simply prefer to import `defineEventHandler` from `nitro/h3` instead:
|
|
157
181
|
|
|
158
|
-
```ts [server/api/
|
|
159
|
-
import { defineEventHandler,
|
|
182
|
+
```ts [server/api/proxy.ts]
|
|
183
|
+
import { defineEventHandler, proxyRequest } from 'nitro/h3'
|
|
160
184
|
|
|
161
|
-
export default defineEventHandler(
|
|
162
|
-
handleCors(event, { origin: '*' })
|
|
163
|
-
return { ok: true }
|
|
164
|
-
})
|
|
185
|
+
export default defineEventHandler(event => proxyRequest(event, 'https://example.com'))
|
|
165
186
|
```
|
|
166
187
|
::
|
|
167
188
|
|
|
168
189
|
## What Isn't Portable
|
|
169
190
|
|
|
170
|
-
|
|
191
|
+
These areas mean reaching outside `nuxt/server`, because Nuxt can't provide them for every builder:
|
|
171
192
|
|
|
172
193
|
- **Storage.** `useStorage()` comes from `nitro/storage`, and so does the driver configuration behind it.
|
|
173
|
-
- **
|
|
174
|
-
- **
|
|
194
|
+
- **Caching.** `defineCachedHandler()` and `defineCachedFunction()` come from `nitro/cache`. For caching that runs anywhere, depend on a cache library directly.
|
|
195
|
+
- **Server plugins and hooks.** `definePlugin()` comes from `nitro`, and the runtime hooks (including `render:html`) from `useNitroHooks()` in `nitro/app`.
|
|
196
|
+
- **App-relative fetch.** `serverFetch()` comes from `nitro`. It calls a route of the app without an origin, which needs the runtime's router.
|
|
197
|
+
- **Lazy handlers.** `lazyEventHandler()` comes from `nitro/h3`.
|
|
175
198
|
|
|
176
199
|
## Server Code Only
|
|
177
200
|
|
|
@@ -9,7 +9,7 @@ links:
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
::warning
|
|
12
|
-
`useServerSeoMeta` is deprecated. Wrap [`useSeoMeta`](/docs/api/composables/use-seo-meta) in an `if (import.meta.server)` block instead.
|
|
12
|
+
`useServerSeoMeta` is deprecated. Wrap [`useSeoMeta`](/docs/api/composables/use-seo-meta) in an `if (import.meta.server)` block instead. It is no longer auto-imported.
|
|
13
13
|
::
|
|
14
14
|
|
|
15
15
|
`useServerSeoMeta` lets you define your site's SEO meta tags as a flat object with full TypeScript support, exactly like [`useSeoMeta`](/docs/api/composables/use-seo-meta), but it only runs server-side and is tree-shaken from the client bundle.
|
|
@@ -23,4 +23,4 @@ export function clearNuxtState (keys?: string | string[] | ((key: string) => boo
|
|
|
23
23
|
|
|
24
24
|
- `keys`: One or an array of keys that are used in [`useState`](/docs/api/composables/use-state) to delete their cached state. If no keys are provided, **all state** will be invalidated.
|
|
25
25
|
- `opts`: An options object to configure the clear behavior.
|
|
26
|
-
- `reset` :badge[v4.4]{color="info" size="xs" class="align-middle"}: When set to `true`, resets the state to the initial value provided by the `init` function of [`useState`](/docs/api/composables/use-state) instead of setting it to `undefined`. When not specified, defaults to the value of `experimental.defaults.useState.resetOnClear` in your Nuxt config (which
|
|
26
|
+
- `reset` :badge[v4.4]{color="info" size="xs" class="align-middle"}: When set to `true`, resets the state to the initial value provided by the `init` function of [`useState`](/docs/api/composables/use-state) instead of setting it to `undefined`. When not specified, defaults to the value of `experimental.defaults.useState.resetOnClear` in your Nuxt config (which defaults to `true`).
|
|
@@ -19,7 +19,7 @@ Read more about `import.meta`.
|
|
|
19
19
|
These values are statically injected and can be used for tree-shaking your runtime code.
|
|
20
20
|
|
|
21
21
|
::note
|
|
22
|
-
`process.browser`, `process.client`, `process.dev`, `process.server`, and `process.test` were soft-deprecated in Nuxt 3.12. In Nuxt 5
|
|
22
|
+
`process.browser`, `process.client`, `process.dev`, `process.server`, and `process.test` were soft-deprecated in Nuxt 3.12. In Nuxt 5, Nuxt no longer augments `NodeJS.Process` with those properties. Prefer the matching `import.meta.*` flags; build-time `process.*` defines still exist for compatibility.
|
|
23
23
|
::
|
|
24
24
|
|
|
25
25
|
Property | Type | Description
|