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#
mkdir my-node-app && cd my-node-app
npm init -y
npm install expressCreate index.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:
{ "scripts": { "start": "node index.js" } }Configure the service#
- In New Project, select Web Service.
- Choose a supported source and connect this project.
- Set Start command to
npm start. - Set Health path to
/health. - 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.