@nuxt/docs-nightly 5.0.0-29560209.2c61a3c1 → 5.0.0-29560959.2cd7cfc5
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/04.views.md +3 -1
- package/1.getting-started/06.styling.md +3 -1
- package/1.getting-started/18.upgrade.md +2 -2
- package/2.directory-structure/1.server.md +5 -2
- package/3.guide/6.going-further/2.hooks.md +3 -1
- package/4.api/5.kit/11.nitro.md +3 -3
- package/4.api/6.nuxt-config.md +1 -1
- package/package.json +1 -1
|
@@ -151,7 +151,9 @@ The callback function of the `render:html` hook allows you to mutate the HTML be
|
|
|
151
151
|
<!-- TODO: figure out how to use twoslash to inject types for a different context -->
|
|
152
152
|
|
|
153
153
|
```ts [server/plugins/extend-html.ts]
|
|
154
|
-
|
|
154
|
+
import { definePlugin } from 'nitro'
|
|
155
|
+
|
|
156
|
+
export default definePlugin((nitroApp) => {
|
|
155
157
|
nitroApp.hooks.hook('render:html', (html, { event }) => {
|
|
156
158
|
// This will be an object representation of the html template.
|
|
157
159
|
console.log(html)
|
|
@@ -160,7 +160,9 @@ Create a plugin in `~~/server/plugins/my-plugin.ts` like this:
|
|
|
160
160
|
<!-- TODO: figure out how to use twoslash to inject types for a different context -->
|
|
161
161
|
|
|
162
162
|
```ts [server/plugins/my-plugin.ts]
|
|
163
|
-
|
|
163
|
+
import { definePlugin } from 'nitro'
|
|
164
|
+
|
|
165
|
+
export default definePlugin((nitro) => {
|
|
164
166
|
nitro.hooks.hook('render:html', (html) => {
|
|
165
167
|
html.head.push('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">')
|
|
166
168
|
})
|
|
@@ -234,7 +234,7 @@ The `nitropack` package has been renamed to `nitro`. All import paths have chang
|
|
|
234
234
|
|---|---|
|
|
235
235
|
| `nitropack` | `nitro` |
|
|
236
236
|
| `nitropack/types` | `nitro/types` |
|
|
237
|
-
| `nitropack/runtime` | `nitro
|
|
237
|
+
| `nitropack/runtime` | `nitro` |
|
|
238
238
|
| `h3` (for server utilities) | `nitro/h3` |
|
|
239
239
|
|
|
240
240
|
Auto-imports within server routes (`defineEventHandler`, `getQuery`, `readBody`, `useRuntimeConfig`, etc.) continue to work without changes.
|
|
@@ -345,7 +345,7 @@ If you define redirect route rules, the property name has changed:
|
|
|
345
345
|
|
|
346
346
|
#### For Module Authors: Additional Changes
|
|
347
347
|
|
|
348
|
-
- **Nitro plugin imports**: Use `import {
|
|
348
|
+
- **Nitro plugin imports**: Use `import { definePlugin } from 'nitro'` for explicit imports (auto-imports still work).
|
|
349
349
|
- **Runtime hooks**: `nitroApp.hooks.hook('beforeResponse', ...)` and `nitroApp.hooks.hook('afterResponse', ...)` have been replaced by `nitroApp.hooks.hook('response', ...)`.
|
|
350
350
|
- **`getRouteRules()` from `nitro/app`**: On the server, the Nitro helper changed from `getRouteRules(event)` to `getRouteRules(method, pathname)`, which returns `{ routeRules }`.
|
|
351
351
|
|
|
@@ -94,7 +94,9 @@ Nuxt will automatically read any files in the `~~/server/plugins` directory and
|
|
|
94
94
|
**Example:**
|
|
95
95
|
|
|
96
96
|
```ts [server/plugins/nitroPlugin.ts]
|
|
97
|
-
|
|
97
|
+
import { definePlugin } from 'nitro'
|
|
98
|
+
|
|
99
|
+
export default definePlugin((nitroApp) => {
|
|
98
100
|
console.log('Nitro plugin', nitroApp)
|
|
99
101
|
})
|
|
100
102
|
```
|
|
@@ -526,9 +528,10 @@ Alternatively, you can create a storage mount point using a server plugin and ru
|
|
|
526
528
|
|
|
527
529
|
::code-group
|
|
528
530
|
```ts [server/plugins/storage.ts]
|
|
531
|
+
import { definePlugin } from 'nitro'
|
|
529
532
|
import redisDriver from 'unstorage/drivers/redis'
|
|
530
533
|
|
|
531
|
-
export default
|
|
534
|
+
export default definePlugin(() => {
|
|
532
535
|
const storage = useStorage()
|
|
533
536
|
|
|
534
537
|
// Dynamically pass in credentials from runtime configuration, or other sources
|
|
@@ -58,7 +58,9 @@ Explore all available App hooks.
|
|
|
58
58
|
These hooks are available for [server plugins](/docs/4.x/directory-structure/server#server-plugins) to hook into Nitro's runtime behavior.
|
|
59
59
|
|
|
60
60
|
```ts [~~/server/plugins/test.ts]
|
|
61
|
-
|
|
61
|
+
import { definePlugin } from 'nitro'
|
|
62
|
+
|
|
63
|
+
export default definePlugin((nitroApp) => {
|
|
62
64
|
nitroApp.hooks.hook('render:html', (html, { event }) => {
|
|
63
65
|
console.log('render:html', html)
|
|
64
66
|
html.bodyAppend.push('<hr>Appended by custom plugin')
|
package/4.api/5.kit/11.nitro.md
CHANGED
|
@@ -200,7 +200,7 @@ You can read more about Nitro plugins in the [Nitro documentation](https://nitro
|
|
|
200
200
|
::
|
|
201
201
|
|
|
202
202
|
::warning
|
|
203
|
-
It is necessary to explicitly import `
|
|
203
|
+
It is necessary to explicitly import `definePlugin` from `` within your plugin file. The same requirement applies to utilities such as `useRuntimeConfig`.
|
|
204
204
|
::
|
|
205
205
|
|
|
206
206
|
### Usage
|
|
@@ -244,9 +244,9 @@ export default defineNuxtModule({
|
|
|
244
244
|
```
|
|
245
245
|
|
|
246
246
|
```ts [runtime/plugin.ts]
|
|
247
|
-
import {
|
|
247
|
+
import { definePlugin } from 'nitro'
|
|
248
248
|
|
|
249
|
-
export default
|
|
249
|
+
export default definePlugin((nitroApp) => {
|
|
250
250
|
nitroApp.hooks.hook('request', (event) => {
|
|
251
251
|
console.log('on request', event.req.url)
|
|
252
252
|
})
|
package/4.api/6.nuxt-config.md
CHANGED