How to deploy a Next.JS application?
Next.js on Vercel vs Hodi: what are the differences?
Vercel is the official platform created by the authors of Next.js.
It offers "automatic" serverless deployment: you push your code to GitHub, and Vercel takes care of the rest (build, scaling, CDN, etc.).
At Hodi, the model is different: you keep full control of your Node.js environment, hosted locally in a Hodi datacenter, with the ability to access files, logs, dependencies, and databases in a traditional way.
Everything runs in a CloudLinux + Phusion Passenger environment, ideal for professional applications requiring:
- data sovereignty,
- improved performance,
- compatibility with other applications (PHP, MySQL databases, etc.).
Prepare your Next.JS application
Run the npm run build command to compile your application, then create — at the root of your project — a server.js file with the following code:
const next = require('next');
const http = require('http');
const { parse } = require('url');
// Passenger automatically sets the port the app should listen on
const port = process.env.PORT || 3000;
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();
app.prepare()
.then(() => {
const server = http.createServer((req, res) => {
try {
const parsedUrl = parse(req.url, true);
handle(req, res, parsedUrl);
} catch (err) {
console.error('Next.js server error:', err);
res.statusCode = 500;
res.end('Internal server error');
}
});
// Passenger uses listen(port) without publicly exposing the port
server.listen(port, () => {
console.log(Next.js running on port ${port});
});
})
.catch((err) => {
console.error('Next.js startup error:', err);
process.exit(1);
});
Transfer your project to your cPanel
Copy your Next.JS folder to the root of your cPanel hosting (for example, via FTP, SSH, etc.).
Configure your project with Setup Node.JS App
You can now follow the FAQ "How to deploy a Node.JS application?" to configure your project. "Application root" will be your folder name, and "Application startup file" will be "server.js".
Updated on: 14/02/2026
Thank you!