Browse all topics

Frameworks

Node.js and Next.js

Settings for Node.js services, Express, and Next.js apps.

Next.js#

SettingValue
RuntimeNode.js
Build commandnpm ci && npm run build
Run commandnpm start

Next.js listens on PORT automatically. Set secrets and public variables (NEXT_PUBLIC_…) in environment variables before the first deploy, because public variables are baked in at build time. If you change a NEXT_PUBLIC_ value later, press Redeploy so the app is rebuilt.

If you only export a static site (output: "export"), choose a static site instead and set the output folder to out.

Express, Fastify and plain Node#

const port = process.env.PORT || 3000;
app.listen(port, "0.0.0.0", () => console.log(`listening on ${port}`));

Run command: node server.js (or npm start).

Node version#

Node.js projects run on Node.js 20. Make sure your dependencies support it.

Files your app writes#

Anything written outside /data disappears on the next deploy. Store uploads and local databases in the folder named by DATA_DIR. See Persistent storage.

Yarn, pnpm and lockfiles#

The build command is yours: yarn install --frozen-lockfile && yarn build or pnpm i && pnpm build both work if the tool is installed by the command (for pnpm: npm i -g pnpm && pnpm i && pnpm build).