# Deploying Node.js applications

> Deploy Node.js applications on Ploi Cloud: connect a repo, set the start command, pick the Node version, configure env vars. Works for Express, Next.js, Nuxt, Hono.

Node.js on Ploi Cloud
---------------------

Ploi Cloud provides comprehensive support for Node.js applications, from simple Express APIs to complex Next.js applications. Deploy your Node.js apps with confidence using our optimized container infrastructure.

### Supported frameworks

Ploi Cloud supports any Node.js framework or application, including:

- **Express.js** - Fast, unopinionated web framework
- **Next.js** - Full-stack React framework
- **Nuxt.js** - Vue.js framework
- **Nest.js** - Progressive Node.js framework
- **Fastify** - High-performance web framework
- **Static site generators** - Gatsby, VitePress, Docusaurus
- **Build tools** - Vite, Webpack, Parcel
- **Custom Node.js applications** - Any application that runs on port 3000

### Deployment modes

Node.js applications can be deployed in two modes:

#### Runtime mode (with start command)
Your application runs as a Node.js server on port 3000. Perfect for:
- APIs and backend services
- Server-side rendered applications
- Real-time applications with WebSockets
- Applications requiring server-side logic

#### Static mode (without start command)
Your built files are served by Nginx on port 8080. Ideal for:
- Single-page applications (SPAs)
- Pre-built static sites
- Generated documentation
- Client-side only applications

### Start command configuration

The start command determines how your application runs:

Common start commands:
- `npm run start` - Default, uses the start script from package.json
- `node server.js` - Direct Node.js execution
- `node dist/index.js` - For TypeScript applications
- `npx next start` - Next.js production server
- `yarn start` - Using Yarn package manager

Leave the start command empty for static file serving.

### Automatic configuration

When you create a Node.js application, Ploi Cloud automatically:

- Sets Node.js version 22 as default
- Configures build commands for your application
- Sets the default start command to `npm run start`
- Installs both npm and yarn package managers
- Configures the correct port based on your deployment mode

### Build commands

Build commands run during the deployment process:

```bash
npm ci
npm run build
```

You can customize these in the Build Configuration section. Common patterns:
- **npm**: `npm ci && npm run build`
- **yarn**: `yarn install --frozen-lockfile && yarn build`

### Database connections

Add database services to your Node.js application:

1. Navigate to your application's Services tab
2. Click "Add service" and select your database type
3. Connection details are automatically injected as environment variables

### Worker services

Run background jobs or long-running processes:

1. Add a Worker service in your application
2. Set the command (e.g., `node worker.js`)
3. Workers share the same code and storage volumes

## Frequently asked questions

### How do I deploy a Node.js application on Ploi Cloud?

Connect your Git repository, pick the Node.js application type, set the start command (e.g. `node server.js` or `npm start`), and add any required environment variables. The platform builds and deploys on every push.

### Which Node.js versions are supported?

Node.js 18, 20, and 22 LTS are supported out of the box. Pick the version in your application settings; the platform installs it during the build.

### How do I set the Node.js start command?

Set the start command in your application settings. Common examples: `npm start`, `node server.js`, `npm run start:prod`. Whatever command keeps your process running in the foreground.

### Does Ploi Cloud support Next.js, Nuxt, and Hono?

Yes. Next.js (App Router and Pages Router), Nuxt 3, Hono, Express, Fastify, NestJS, and any other Node.js framework that listens on a configurable port works out of the box. See the dedicated Next.js guide for SSR-specific configuration.

### How do I add custom build steps for a Node.js app?

Add commands to the build configuration in your application settings. Typical additions: `npm install --production`, `npm run build`, or `npx prisma generate`. They run in order during the Docker build before your start command takes over.
