Skip to content
Dashboard

Node.js Quickstart

Deploy a small Node.js HTTP application as a NexHost Web Service.

Node.js Quickstart#

This quickstart deploys a small HTTP application as a Web Service. Use Frontend App instead for a server-rendered Next.js or similar UI.

Create the application#

bash
mkdir my-node-app && cd my-node-app
npm init -y
npm install express

Create index.js:

js
const express = require("express");
const app = express();
const port = Number(process.env.PORT);

app.get("/", (_request, response) => response.send("Hello from NexHost"));
app.get("/health", (_request, response) => response.status(200).json({ ok: true }));

app.listen(port, "0.0.0.0");

Set the start script in package.json:

json
{ "scripts": { "start": "node index.js" } }

Configure the service#

  1. In New Project, select Web Service.
  2. Choose a supported source and connect this project.
  3. Set Start command to npm start.
  4. Set Health path to /health.
  5. Deploy and open the generated hostname shown by the dashboard.

The server must use process.env.PORT and bind to 0.0.0.0. See Deployment Troubleshooting if the health check fails.