BabalCloud Logo
PricingAboutBlog
Log inGet Started
BabalCloud

Empowering businesses with reliable, scalable, and secure cloud hosting solutions. Our infrastructure is designed for performance, uptime, and peace of mind.

Products

  • Pricing
  • Domain Registration
  • Domain Transfer

Company

  • About Us
  • Blog
  • Contact

Legal

  • Privacy Policy
  • Terms of Service

© 2026 BabalCloud Private Limited. All rights reserved.

Proudly serving developers in Nepal.

Back to blog
Developers

Deploy a Next.js or React App to cPanel: What Works and What Doesn't

An honest guide to hosting React and Next.js apps on cPanel shared hosting — what deploys cleanly, what needs Node.js, when static export works, and when you actually need a VPS.

BabalCloud TeamJuly 22, 20266 min read

"Can I host my React or Next.js app on cPanel shared hosting?" The honest answer is: it depends entirely on whether your app is static or needs a server. A static React site deploys to cPanel in minutes. A server-rendered Next.js app needs Node.js support — and sometimes a VPS. This guide draws the line clearly so you don't waste an afternoon fighting the wrong setup.

We'll cover each case, what to actually do, and how to automate the deploy once it's working.

Not sure which plan fits your app? BabalCloud's hosting plans support both static sites and Node.js apps, and our automated GitHub pipeline handles the build-and-deploy step for you.

The key question: static or server-rendered?

Everything comes down to one distinction:

  • Static — your app compiles to plain HTML, CSS, and JavaScript files. No server runs your code; the browser does all the work. This includes Create React App, Vite React apps, and Next.js in static export mode. These host on any cPanel plan.
  • Server-rendered / dynamic — your app needs Node.js running on the server to render pages, handle API routes, or do server-side rendering (SSR). This includes standard Next.js with SSR, getServerSideProps, API routes, and middleware. These need Node.js support (available on many cPanel plans via "Setup Node.js App") or a VPS.

Figure out which bucket your app is in first — it decides everything else.

Case 1: A static React app (easiest)

If you built with Create React App or Vite and don't need a backend on the same host, you're in the easy path.

Step 1 — Build locally

npm run build

Create React App outputs to build/; Vite outputs to dist/. This folder contains your entire deployable site.

Step 2 — Upload the build folder

In cPanel File Manager, upload the contents of your build/ or dist/ folder into public_html/. That's it — your site is live.

Step 3 — Fix client-side routing (important)

Single-page apps using React Router will 404 on page refresh because the server looks for a real file at that path. Add a .htaccess file in public_html to redirect everything back to index.html:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

This is the single most common "my routes work locally but break on the server" fix.

Case 2: Next.js with static export

Next.js can produce a fully static site if your app doesn't use server-only features. Set the export mode in next.config.js:

const nextConfig = {
  output: 'export',
};
module.exports = nextConfig;

Then build:

npm run build

Next.js writes a static site to the out/ folder. Upload the contents of out/ to public_html, add the .htaccess rule above, and you're done — all on standard shared hosting.

The catch: static export disables server-side rendering, API routes, getServerSideProps, image optimization (unless configured), and middleware. If your app relies on those, you're in Case 3.

Case 3: Next.js with SSR or Node.js apps

If your app genuinely needs a running Node.js server, you have two options.

Option A — cPanel's "Setup Node.js App"

Many cPanel hosts (BabalCloud included) offer a Setup Node.js App tool that runs Node applications using Phusion Passenger. The general flow:

  1. Upload your project (excluding node_modules) to a folder like ~/nodeapp.
  2. In cPanel → Setup Node.js App, create an application, set the Node version, application root, and startup file.
  3. Click Run NPM Install, then set your start command (e.g. npm start).
  4. Map it to your domain.

This works well for Express APIs and smaller Next.js apps. Very heavy or high-traffic apps may outgrow shared limits.

Option B — A VPS

If you need full control — custom Node versions, PM2 process management, websockets, or high concurrency — a VPS is the right tool. You get root access to run Node exactly how you want behind Nginx. This is the standard choice for production SSR apps at scale.

Rule of thumb: static or light Node app → shared cPanel is fine. Heavy SSR, real-time features, or high traffic → VPS.

Automate the deploy

Whichever case you're in, automate it so you never upload by hand again. A GitHub Actions workflow can build your app and push the output to cPanel on every commit:

name: Build and Deploy
 
on:
  push:
    branches: [main]
 
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
      - run: npm ci
      - run: npm run build
      - name: Upload to cPanel
        uses: SamKirkland/[email protected]
        with:
          server: ${{ secrets.FTP_SERVER }}
          username: ${{ secrets.FTP_USERNAME }}
          password: ${{ secrets.FTP_PASSWORD }}
          local-dir: ./out/   # or ./build/ or ./dist/
          server-dir: ./public_html/

For the full secrets-and-workflow walkthrough, see our guide on auto-deploying from GitHub to cPanel.

Frequently asked questions

Can I host a Next.js app on shared cPanel hosting?

Yes, if you use static export (output: 'export') or your host offers Node.js app support. Full server-side rendering at scale is better suited to a VPS.

Why does my React app 404 when I refresh a page?

Your server is looking for a real file at that route. Add a .htaccess rewrite that sends all non-file requests back to index.html, so React Router can handle routing client-side.

Do I need Node.js on the server for a React app?

Not for a static build — the compiled HTML/CSS/JS runs entirely in the browser. You only need server-side Node.js for SSR, API routes, or a Node backend.

Should I use static export or SSR for Next.js?

Use static export if your content doesn't change per-request — it's faster, cheaper, and hosts anywhere. Use SSR when you need per-request rendering, authentication, or dynamic API routes.

When do I need a VPS instead of shared hosting?

When you need full server control: custom Node versions, PM2, websockets/real-time features, or when traffic outgrows shared plan limits.

Summary

Hosting React or Next.js on cPanel isn't hard once you know which case you're in. Static builds drop straight into public_html (don't forget the .htaccess rewrite). Static-export Next.js works the same way. Only true SSR and heavier Node apps need Node.js app support or a VPS.

If you want a host that handles both — static sites and Node apps — with automated GitHub deployment built in, BabalCloud is designed for exactly this kind of modern JavaScript workflow.

#Next.js#React#cPanel#Deployment#Node.js
Share

On this page

  • The key question: static or server-rendered?
  • Case 1: A static React app (easiest)
  • Step 1 — Build locally
  • Step 2 — Upload the build folder
  • Step 3 — Fix client-side routing (important)
  • Case 2: Next.js with static export
  • Case 3: Next.js with SSR or Node.js apps
  • Option A — cPanel's "Setup Node.js App"
  • Option B — A VPS
  • Automate the deploy
  • Frequently asked questions
  • Can I host a Next.js app on shared cPanel hosting?
  • Why does my React app 404 when I refresh a page?
  • Do I need Node.js on the server for a React app?
  • Should I use static export or SSR for Next.js?
  • When do I need a VPS instead of shared hosting?
  • Summary