DockHostingDocs
Stacks

Node.js, Next.js and NestJS

Deploy Express, Fastify, Next.js, Nuxt, NestJS or any Node.js app.

What we detect

A package.json at your app's root makes it a Node.js app. We recognise Next.js, Nuxt, NestJS, Express, Fastify, Koa and Hono from your dependencies.

  • Install: npm, yarn or pnpm, from your lockfile.
  • Build: your build script, if there is one.
  • Start: your start script.
  • Node version: the one in .nvmrc, .node-version or engines in package.json; otherwise Node 22.

Listen on PORT

server.js
const express = require("express");
const app = express();

app.get("/", (req, res) => res.send("Hello from DockHosting"));

const port = process.env.PORT || 3000;
app.listen(port, "0.0.0.0", () => console.log(`listening on ${port}`));
package.json
{
  "scripts": {
    "start": "node server.js"
  }
}

Next.js

Next.js works as-is: we run next build, then next start, which reads PORT.

package.json
{
  "scripts": {
    "build": "next build",
    "start": "next start"
  }
}

NEXT_PUBLIC_ variables are baked in at build time

Set NEXT_PUBLIC_* variables before deploying. After changing one, redeploy so the build picks it up.

NestJS

NestJS builds with nest build. Listen on PORT in main.ts:

src/main.ts
const app = await NestFactory.create(AppModule);
await app.listen(process.env.PORT ?? 3000, "0.0.0.0");
package.json
{
  "scripts": {
    "build": "nest build",
    "start": "node dist/main"
  }
}

Databases

Link a database and read DATABASE_URL: Prisma, Drizzle, Sequelize, TypeORM, Mongoose and pg all accept a connection URL. For MongoDB, read MONGODB_URI; for Redis, REDIS_URL.

prisma/schema.prisma
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

Run migrations on start

Prisma: start with npx prisma migrate deploy && node server.js (in the start script, or the start command in Settings).

On this page