How to Deploy a Next.js App in cPanel Print

  • Updated on 13-Nov-2026
  • 0

How to Deploy a Next.js App in cPanel

Can I host Next.js on cPanel hosting? Yes. A static Next.js site runs on every HosterPK plan. A Next.js app with server rendering or API routes runs as a Node.js app through "Setup Node.js App" in cPanel; we recommend Hosting Plan II or above. You do not need SSH.

Which kind is your app?

  • Static export (output: 'export' in next.config.js): run npm run build on your computer and upload the contents of the out folder to public_html. Nothing else is needed.
  • Server rendering or API routes: follow the steps below.

Steps for a server-rendered app

  1. Build on your computer. Run npm run build. The build does not run on shared hosting, so do not skip this step.
  2. Add a start-up file named server.js to the top folder of the project. cPanel starts your app itself, so next start is not used. This is the file tested on our servers:
    const { createServer } = require('http'); const next = require('next'); const app = next({ dev: false, dir: __dirname }); const handle = app.getRequestHandler(); app.prepare().then(() => { createServer((req, res) => handle(req, res)).listen(process.env.PORT || 3000); });
  3. Upload the project to a folder outside public_html, for example myapp. Include the .next folder. Do not upload the node_modules folder.
  4. Create the app. In cPanel open "Setup Node.js App" and click CREATE APPLICATION, then fill in the form:
    • Node.js version: choose 24.
    • Application mode: change "Development" to "Production".
    • Application root: the folder from step 3, for example myapp.
    • Application URL: choose your domain. Leave the box beside it empty to run the app on the whole domain.
    • Application startup file: server.js
    • Environment variables: click ADD VARIABLE for each value your app needs, such as a database password.
    Click CREATE.
  5. Install the packages. Under "Detected configuration files" click Run NPM Install. For a Next.js app this takes about 10 minutes; wait for it to finish.
  6. Click RESTART and open your address.

How much space it needs

A minimal Next.js app installs about 350 MB of packages. On real apps hosted with us the figure is 500 to 900 MB. That is why we recommend Hosting Plan II (2,000 MB) or above.

Changing the Node.js version later

  1. Open the app in "Setup Node.js App", choose the new version under Node.js version and click SAVE.
  2. cPanel reinstalls your packages for the new version by itself. In our test this took about 5 minutes, and the site answered slowly meanwhile.
  3. Click RESTART. Until you do, the app keeps running on the old version.

The old version's packages stay on your account, so each version you have used takes its own space: about 350 MB each for a small Next.js app.

If the build fails on the server

That is expected. Running the Next.js build on shared hosting, including through the Run JS script button, stops with an error such as "Out of memory". Build on your computer and upload the project with its .next folder, as in steps 1 and 3.

Tested: these steps were tested on our cPanel servers on 13 November 2026 with Next.js 16 on Node.js 20 and Node.js 24.

Still stuck? Open a support ticket or start a live chat, and we will create the app, install the packages and start it for you. See the plans on our Node.js hosting page.


Was this answer helpful?

« Back