Nitro
Nuxt Kit provides a set of utilities to help you work with Nitro. These functions allow you to add server handlers, plugins, and prerender routes. Nitro is an open source TypeScript framework to build ultra-fast web servers. Nuxt uses Nitro as its server engine.addServerHandler
Adds a Nitro server handler. Use this if you want to create server middleware or a custom route.
Type
Parameters
handler: A handler object with the following properties:
Usage
addDevServerHandler
Adds a Nitro server handler to be used only in development mode. This handler will be excluded from production build.
Type
Parameters
handler: A handler object with the following properties:
Usage
useNitro
Returns the Nitro instance.
Warning: You can call useNitro() only after ready hook.
Note: Changes to the Nitro instance configuration are not applied.
Type
Usage
addServerPlugin
Add plugin to extend Nitro’s runtime behavior.
Warning: It is necessary to explicitly import defineNitroPlugin from nitropack/runtime within your plugin file.
Type
Parameters
Usage
addPrerenderRoutes
Add routes to be prerendered to Nitro.
Type
Parameters
Usage
addServerImports
Add imports to the server. It makes your imports available in Nitro without the need to import them manually.
Type
Parameters
imports: An object or an array of objects with the following properties:
Usage
addServerImportsDir
Add a directory to be scanned for auto-imports by Nitro.
Type
Parameters
Usage
addServerScanDir
Add directories to be scanned by Nitro. It will check for subdirectories, which will be registered just like the ~~/server folder is.
Note: Only ~~/server/api, ~~/server/routes, ~~/server/middleware, and ~~/server/utils are scanned.