The Node.js server preset is the default output format if none is specified or auto-detected by Nitro.
Why Choose Node.js Deployment
Full SSR Support
Complete server-side rendering for every request
Optimized Performance
Loads only required chunks for optimal cold start timing
Universal Compatibility
Works with any Node.js hosting provider
Dynamic Content
Serve personalized content per request
Building for Production
1
Build your application
Run the build command to create a production-ready Node.js server:
2
Review the output
The build creates an optimized server in the
.output directory:3
Start the server
Launch your production Nuxt server:Your server will start on port 3000 by default.
Environment Variables
The Node.js server respects the following runtime environment variables:string | number
default:"3000"
The port the server listens on. Also accepts
PORT.string
default:"0.0.0.0"
The host address to bind to. Also accepts
HOST.string
Path to SSL certificate file. Requires
NITRO_SSL_KEY to enable HTTPS.string
Path to SSL private key file. Requires
NITRO_SSL_CERT to enable HTTPS.Example Configuration
.env
Process Management with PM2
PM2 is a production-grade process manager for Node.js applications. It provides process monitoring, automatic restarts, and cluster mode support.Installing PM2
Basic PM2 Configuration
Create anecosystem.config.cjs file in your project root:
ecosystem.config.cjs
PM2 Commands
Advanced PM2 Configuration
ecosystem.config.cjs
Cluster Mode
Leverage multi-core systems by running multiple Node.js processes:Using Nitro Cluster Preset
Set the cluster preset when building:nuxt.config.ts:
nuxt.config.ts
Cluster Configuration
Configure cluster behavior:nuxt.config.ts
Deployment Platforms
Deploy your Node.js Nuxt application to popular platforms:- DigitalOcean
- Railway
- Render
- Heroku
Deploy to DigitalOcean App Platform
- Push your code to GitHub/GitLab
- Create a new App in DigitalOcean
- Connect your repository
- Configure build settings:
- Build Command:
npm run build - Run Command:
node .output/server/index.mjs
- Build Command:
- Set environment variables
- Deploy
Docker Deployment
Containerize your Nuxt application:Dockerfile
Build and Run
Docker Compose
docker-compose.yml
Reverse Proxy Setup
Nginx Configuration
/etc/nginx/sites-available/nuxt-app
Apache Configuration
/etc/apache2/sites-available/nuxt-app.conf
Performance Optimization
Enable compression
Enable compression
nuxt.config.ts
Configure caching
Configure caching
nuxt.config.ts
Database connection pooling
Database connection pooling
server/utils/db.ts
Memory management
Memory management
Monitor memory usage and configure limits:
Troubleshooting
Port already in use
Port already in use
Change the port using environment variables:
Module not found errors
Module not found errors
Ensure all dependencies are installed in production:
Memory leaks
Memory leaks
Monitor with PM2:
Slow cold starts
Slow cold starts
The Node.js preset is optimized for minimal cold start time. Consider:
- Reducing bundle size
- Using dynamic imports
- Implementing route-level code splitting
Next Steps
Edge Deployment
Deploy to edge networks for lower latency
Deployment Overview
Explore other deployment options