Skip to main content
The Node.js server preset allows you to deploy your Nuxt application to any Node.js hosting environment with full server-side rendering (SSR) support.
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.
Only use for local testing. In production, use a reverse proxy like nginx or Cloudflare to terminate SSL.
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 an ecosystem.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:
Or configure in nuxt.config.ts:
nuxt.config.ts
By default, the workload is distributed to workers using the round-robin strategy.

Cluster Configuration

Configure cluster behavior:
nuxt.config.ts

Deployment Platforms

Deploy your Node.js Nuxt application to popular platforms:

Deploy to DigitalOcean App Platform

  1. Push your code to GitHub/GitLab
  2. Create a new App in DigitalOcean
  3. Connect your repository
  4. Configure build settings:
    • Build Command: npm run build
    • Run Command: node .output/server/index.mjs
  5. Set environment variables
  6. 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

nuxt.config.ts
nuxt.config.ts
server/utils/db.ts
Monitor memory usage and configure limits:

Troubleshooting

Change the port using environment variables:
Ensure all dependencies are installed in production:
Monitor with PM2:
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