Nitro is a robust server engine designed to extend Vite applications with production-ready, universal JavaScript servers that can be deployed across various platforms. Currently, Nitro v3 (`3.0.260415-beta`) is in beta, actively developed with highlights including experimental tracing channels, smarter dependency tracing, and an upgrade to H3 v2, which introduces web standard primitives. The stable version remains v2. Nitro differentiates itself by offering a zero-config experience, automatic file-system based routing for API endpoints, and a focus on performance with compile-time route processing, leading to minimal server bundles. It enables developers to build full-stack applications with capabilities like built-in task runners, scheduled cron jobs, and cross-environment WebSocket support. Releases are frequent, with beta versions seeing rapid iteration and stable versions receiving dependency updates and security fixes.
npm install nitroVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up a basic Nitro server with a configuration file, define a simple API route using `defineHandler`, and access both public and private runtime configurations.
Refer to the official Nitro v3 migration guide for a comprehensive list of changes and updated code patterns. Update package names and import paths accordingly.
Ensure your Node.js environment (local, CI/CD, hosting provider) is updated to Node.js 20 LTS or a later compatible version.
Migrate configuration to use `nitro.config.ts` and `useRuntimeConfig()` or import regular `.ts` files from your `server` directory directly.
Monitor official releases and the migration guide regularly. Be prepared for potential API adjustments if using beta versions in production-like environments.
Always use the latest documented import path for `useRuntimeConfig`: `import { useRuntimeConfig } from 'nitro/runtime-config'`. Explicitly import it, as auto-import might not correctly resolve older paths.Rename `nitropack` dependency to `nitro` in `package.json` and update all imports from `nitropack/*` to `nitro/*`.
Ensure you explicitly `import { useRuntimeConfig } from 'nitro/runtime-config'` in your server-side files.Replace `eventHandler` with `defineHandler` and ensure it's imported correctly: `import { defineHandler } from 'nitro'`.Ensure all dependencies are compatible with ESM or investigate using Nitro's experimental features related to dependency tracing and `nf3` improvements to better handle native packages and optional dependencies.