Skip to content
Fleeq Hosting

Node & Next.js apps

The Node plan runs your JavaScript or TypeScript app and publishes it on its own HTTPS address.

Your app must listen on the port in the SERVER_PORT environment variable, on all interfaces:

index.js
import http from 'node:http';
const port = Number(process.env.SERVER_PORT);
http
.createServer((req, res) => res.end('Hello from Fleeq\n'))
.listen(port, '0.0.0.0', () => console.log(`listening on ${port}`));

Express: app.listen(process.env.SERVER_PORT, '0.0.0.0'). An app listening on 3000 or localhost isn’t reachable.

On every start the runtime:

  1. installs any extra packages listed in NODE_PACKAGES;
  2. runs npm install if there’s a package.json;
  3. starts MAIN_FILE (default index.js) with node, or with ts-node --esm if it ends in .ts.

Set MAIN_FILE in Startup if your entry point is elsewhere (dist/server.js, src/index.ts).

Build on your computer or in CI, upload the project including .next/, and start Next’s server from a small entry file:

start.js
import { spawn } from 'node:child_process';
spawn('npx', ['next', 'start', '-H', '0.0.0.0', '-p', process.env.SERVER_PORT], { stdio: 'inherit' });

Set MAIN_FILE to start.js. A plain next build on the server works too, but uses much of the plan’s memory while it runs.

Instead of uploading files, let the server clone your repository:

Variable Set to
USER_UPLOAD 0 — install from Git instead of your uploads
GIT_ADDRESS your repository’s HTTPS URL
BRANCH the branch to deploy (default branch if empty)
USERNAME, ACCESS_TOKEN for a private repository: a user and a personal access token with read access
AUTO_UPDATE 1 to git pull on every start

Then Settings → Reinstall server. With AUTO_UPDATE on, deploying a new version is a Restart.

Put settings in a .env file next to your code (in Files) and load it when your app starts — with the dotenv package (import 'dotenv/config'), or Node’s built-in process.loadEnvFile(). Don’t commit .env to Git.

NODE_ARGS is appended after your start file, so it reaches your app as process.argv — it can’t pass flags to Node itself.

Everything your app prints goes to the Console. If the app crashes, the last lines there say why.