KamuiDash KamuiDash Docs
EN JA ZH

Deploy Node.js and Next.js Apps

Deploy a Node.js application that connects to PostgreSQL using DB migrations.

Assumed Structure

  • Entry point: node/index.js, started via npm run start
  • Migrations: managed under node/migrations, run via npm run migrate
  • DATABASE_URL is assembled inside scripts from the individual environment variables

Deploy Commands

Field Value (example)
Setup Command npm install
Pre-start Command npm run migrate
Start Command npm run start

All commands run from the repository root.

package.json Scripts

Define the following scripts in package.json:

{
  "scripts": {
    "start": "node node/index.js",
    "migrate": "node node/migrations/migrate.js",
    "migrate:down": "node node/migrations/migrate-down.js"
  }
}

Deploy a Next.js app

If your Next.js app needs a server, deploy it as a Node.js Web Server. With an npm lockfile, use npm ci && npm run build as the setup command. Set your start script to next start -H 0.0.0.0 and use npm run start as the start command. Next.js reads the PORT supplied by KamuiDash.

See the Next.js deployment guide for the full setup and when you can use static export instead.

Environment Variables

The PORT environment variable is set by default. Your app should use this value as the listen port.

When a database is selected during app creation, the following variables are also automatically set:

  • DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD
  • DATABASE_URL — full connection string

Use these to build the connection in your migration scripts and application code.

Starter App

See the starter app for reference: kamui-project/node-starter

Next Steps