How do I deploy a Next.js application?
Next.js on Vercel vs Hodi: what's the difference?
Vercel is the official platform created by the authors of Next.js.
It offers "automatic" deployment with no visible server: 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 the usual way.
The whole thing runs in a CloudLinux + Phusion Passenger environment, ideal for professional applications that need:
- data sovereignty,
- improved performance,
- compatibility with other applications (PHP, MySQL databases, etc.).
Prepare your Next.js application
Run the npm run build command to build 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('Error starting Next.js:', 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.).
Set up your project with Setup Node.js App
You can now follow the FAQ "How do I deploy a Node.js application?" to configure your project. "Application root" will be the name of your folder, and "Application startup file" will be "server.js".
Updated on: 17/07/2026
Thank you!