From 846eaf330b96fc5a6f33a766c7e396f0bd24146a Mon Sep 17 00:00:00 2001 From: julien huang Date: Fri, 23 Sep 2022 09:24:09 +0200 Subject: [PATCH 1/2] docs(guide): add Nitro plugins to directory structure --- .../2.guide/2.directory-structure/1.server.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/content/2.guide/2.directory-structure/1.server.md b/docs/content/2.guide/2.directory-structure/1.server.md index ff942672fb7..b35dd384e68 100644 --- a/docs/content/2.guide/2.directory-structure/1.server.md +++ b/docs/content/2.guide/2.directory-structure/1.server.md @@ -66,6 +66,21 @@ export default defineEventHandler((event) => { }) ``` +## Server Plugins + +Nuxt will automatically read any files in the `~/server/plugins` directory and register them as nitro plugins to extends its behavior. + +**Example:** + +```ts [server/plugins/nitroPlugin.ts] +export default defineNitroPlugin((nitroApp) => { + console.log('Nitro plugin', nitroApp) +}) +``` + +::ReadMore{link="https://nitro.unjs.io/guide/advanced/plugins" title="Nitro Plugins"} +:: + ## Server Utilities Server routes are powered by [unjs/h3](https://github.com/unjs/h3) which comes with a handy set of helpers. From 58fdb8a2f6fb3576b28f680b2965ccd8870a47be Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 23 Sep 2022 09:23:12 +0100 Subject: [PATCH 2/2] docs: tweak --- docs/content/2.guide/2.directory-structure/1.server.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/2.guide/2.directory-structure/1.server.md b/docs/content/2.guide/2.directory-structure/1.server.md index b35dd384e68..5bf170d59c0 100644 --- a/docs/content/2.guide/2.directory-structure/1.server.md +++ b/docs/content/2.guide/2.directory-structure/1.server.md @@ -68,7 +68,7 @@ export default defineEventHandler((event) => { ## Server Plugins -Nuxt will automatically read any files in the `~/server/plugins` directory and register them as nitro plugins to extends its behavior. +Nuxt will automatically read any files in the `~/server/plugins` directory and register them as Nitro plugins. This allows extending Nitro's runtime behavior and hooking into lifecycle events. **Example:**