Overview
Nitro can generate different output formats suitable for different hosting providers from the same code base. Using built-in presets, you can easily configure Nitro to adjust its output format with almost no additional code or configuration!
Default output
The default production output preset is Node.js server.
When running Nitro in development mode, Nitro will always use a special preset called nitro-dev
using Node.js with ESM in an isolated Worker environment with behavior as close as possible to the production environment.
Zero-Config Providers
When deploying to production using CI/CD, Nitro tries to automatically detect the provider environment and set the right one without any additional configuration required. Currently, the providers below can be auto-detected with zero config.
Changing the deployment preset
If you need to build Nitro against a specific provider, you can target it by defining an environment variable named NITRO_PRESET
or SERVER_PRESET
, or by updating your Nitro configuration or using --preset
argument.
Using the environment variable approach is recommended for deployments depending on CI/CD.
Example: Defining a NITRO_PRESET
environment variable
nitro build --preset cloudflare_pages
Example: Updating the nitro.config.ts
file
export default defineNitroConfig({
preset: 'cloudflare_pages'
})