NHRepon
Home
Services
All ServicesWeb Application DevelopmentMobile Application DevelopmentDigital Marketing and SEO
ProjectsToolsProductsPostsAboutContactLogin
HomeServicesProjectsToolsProductsPostsAboutContact
  • Home
  • Projects
  • Posts
Home/Posts/How to Deploy a Next.js App to cPanel Shared Hosting

How to Deploy a Next.js App to cPanel Shared Hosting

How to Deploy a Next.js App to cPanel Shared Hosting
Nur Hossain ReponWeb DevelopmentOct 20, 20266 min read2 Comments
  • Key takeaways
  • First, find out what the host actually supports
  • Two deployment models
  • Option A: deploy a static export
  • Option B: deploy a Node.js application
  • Environment variables and secrets
  • Images, caching and Server Actions
  • Database, email and cron
  • Troubleshooting
  • When to move off shared hosting
  • Frequently asked questions
  • Sources and further reading
  • Related services

cPanel shared hosting can run a Next.js app in two ways: as a fully static export, or as a Node.js application on a host that explicitly supports a Node runtime. A standard PHP-only shared plan cannot run Server Actions, dynamic routes or a Next.js server.

Key takeaways

  • Ask the host three questions before you build: which Node versions, which application runtime (Passenger/Web Apps), and whether a custom start command is allowed.
  • Static export is the safest option on constrained shared hosting; it removes the Node server but also removes Server Actions, dynamic rendering and built-in image optimisation.
  • A Node deployment needs the standalone build, a startup file, environment variables and a process that the host keeps alive.
  • Test HTTPS, redirects, forms, images and the 404 page on the real domain before calling it done.

First, find out what the host actually supports

cPanel is a control panel, not a runtime. Two hosts can show the same cPanel theme and have very different Node support. Before you upload anything, ask support for the following in writing.

QuestionWhy it matters
Which Node.js versions are available?Next.js requires a modern Node version; a mismatch breaks the build or runtime.
Is Passenger, Setup Node.js App or Web Apps enabled?This determines how the application is started and kept alive.
Can I set a custom startup file and environment variables?Next.js standalone needs server.js and production env values.
Is SSH or a terminal available?You may need it to install dependencies or inspect logs.
What are the memory, process and entry-process limits?Next.js builds and server rendering can exceed shared limits.
Which database and outbound ports are allowed?Remote Postgres/MySQL and SMTP are often restricted.
Is cron available?Scheduled jobs need a cron entry, not a long-running worker.

Two deployment models

ModelWhat worksWhat you lose
Static export (output: 'export')Pages, client components, static assets, contact forms via an external APIServer Actions, dynamic routes at request time, ISR, next/image optimisation, middleware
Node.js applicationSSR, Server Actions, Route Handlers, dynamic routes, ISR with a writable cacheRequires a supported Node runtime, more memory and a process the host keeps alive

Option A: deploy a static export

  1. Set the export config. In next.config.ts, set output: 'export' and images.unoptimized: true unless you use a separate image CDN.
  2. Build locally or in CI. Run npm ci and npm run build with the same Node major version the host will serve.
  3. Find the output. Next.js writes the static site to out/.
  4. Upload the contents of out/. Use cPanel File Manager or SFTP. Put the files in public_html or the domain's document root.
  5. Add redirects and headers. Use .htaccess for redirects, HTTPS and cache headers. Test that the rules do not break Next.js routes.
  6. Handle 404s. Create a 404.html in the export and point Apache at it, or use the host's error-page setting.
  7. Test on the domain. Check every route, form, image, canonical URL and the trailing-slash behaviour.

Static export is a good fit for a marketing site, documentation, a portfolio or a client-rendered app that talks to an external API. It is a poor fit for authenticated dashboards that need server-side session checks, Server Actions or request-time personalisation.

Option B: deploy a Node.js application

  1. Build the standalone output. Set output: 'standalone' and run the production build. The standalone folder contains server.js and the traced dependencies.
  2. Assemble the upload. Copy public/ into .next/standalone/public and .next/static into .next/standalone/.next/static.
  3. Create the application in cPanel. Open the Node.js selector, choose the supported Node version, set the application root and the startup file to server.js.
  4. Install production dependencies. If the host does not include them in the upload, run npm ci --omit=dev in the application root using the host's Node environment.
  5. Set environment variables. Add production values in the cPanel UI. Do not upload a .env file into public_html.
  6. Start and map the domain. Start the app, confirm the temporary URL works, then map the domain and force HTTPS.
  7. Check logs and memory. Open the application logs, watch for restarts and confirm the process stays alive under a real request.
  8. Test the full journey. Auth callback, form submission, image loading, redirects, 404s and a hard refresh on a deep route.

Environment variables and secrets

  • Keep .env files outside the public web root and set permissions so they are not world-readable.
  • Use the cPanel environment-variable UI where possible; it survives redeploys better than a file.
  • Never expose server keys through NEXT_PUBLIC_*; those values are embedded in the browser bundle.
  • Use a separate database and auth callback for staging. A preview that writes to production is not a preview.

Images, caching and Server Actions

  • With static export, next/image cannot optimise on the server; set unoptimized: true or use a CDN with resizing.
  • With a Node app, keep the image optimiser enabled only if the host has enough memory and a writable cache.
  • ISR needs a persistent, writable cache. If the host wipes the filesystem on restart, use static generation or on-demand revalidation with a durable cache.
  • Server Actions require the Node runtime and a correct NEXTAUTH_URL/site URL. Test them on the real domain, not just localhost.

Database, email and cron

Shared hosting often provides MySQL but not Postgres. If your app needs Postgres, confirm that a remote database is allowed and that outbound TLS works. Use a connection pool or a serverless driver, because shared process limits are low. For email, use an SMTP provider rather than the host's local mail service; transactional email needs authentication and delivery monitoring.

Use cPanel cron for scheduled tasks such as sitemap refresh, cleanup or reminders. Do not use it for long-running workers or queues. If the app needs background processing, run a separate worker on a VPS or a managed queue.

Troubleshooting

SymptomLikely causeFix
500 on every routeNode version mismatch or missing dependenciesMatch the build/runtime version and reinstall production dependencies
Static assets 404Files uploaded to the wrong rootPut _next/static at the correct path inside the app root
Deep link 404Apache is not rewriting to the appConfigure the Node app or add the correct rewrite rules
Images brokenImage optimiser unavailable or static exportUse unoptimized or a CDN loader
Forms failServer Action/API route not runningConfirm the Node runtime and the site URL
App restarts randomlyMemory or process limitReduce concurrency, move to a larger plan or a VPS
HTTPS mixed contentHard-coded http:// URLsUse relative URLs or the production HTTPS origin

When to move off shared hosting

  • You need Server Actions, request-time personalisation or ISR with reliable caching.
  • The app needs a Postgres database, Redis, WebSockets or background workers.
  • The host cannot guarantee memory, process count or a supported Node version.
  • You need preview deployments, rollbacks or observability that cPanel does not provide.

A small VPS with a deployment panel or a managed platform is often cheaper than the engineering time spent fighting shared-host limits. Move when the constraint is structural, not when a single support ticket can fix it.

Frequently asked questions

No. You need either static export support (any host can serve the files) or a Node.js application runtime. A PHP-only plan cannot run the Next.js server.

No. Server Actions require a running server. Static export produces HTML, CSS and JavaScript only.

Sometimes. Confirm the database type, remote access, connection limits and TLS. A remote Postgres database may be blocked or too slow from a shared host.

Build in CI or locally, upload the new output, and keep the previous release for rollback. For a Node app, restart the application after replacing the files.

The usual causes are a different Node version, missing environment variables, a case-sensitive Linux filesystem, a blocked outbound port or a process/memory limit.

Sources and further reading

  • Next.js deployment guide (nextjs.org)
  • Next.js self-hosting guide (nextjs.org)
  • cPanel Node.js application documentation (docs.cpanel.net)

Related services

  • Next.js full-stack development
  • Web application development
  • Contact

Stuck on a cPanel deployment?

Send the error, the Node version and the hosting plan. I will tell you whether it is fixable or whether a small VPS is the cheaper path.

Start a short, no-pressure conversation →

How to cite this guide: Nur Hossain Repon, “How to Deploy a Next.js App to cPanel Shared Hosting”, Nhrepon Portfolio, reviewed October 2026, https://nhrepon.com/posts/deploy-nextjs-to-cpanel.

#next.js#cpanel#deployment#web development
5 Likes195 Views2 Shares
Share:

Related Posts

Hire a Full-Stack Developer in the UK: a buyer's guide
adminOct 18, 2026
Web Development

Hire a Full-Stack Developer in the UK: a buyer's guide

0 views0 likes0 shares
Next.js 15 new hooks and features deep dive 2026
adminOct 18, 2026
Web Development

Next.js 15 new hooks and features deep dive 2026

1 views0 likes0 shares
Migrate jQuery to React 2026 cost guide
adminOct 18, 2026
Web Development

Migrate jQuery to React 2026 cost guide

0 views0 likes0 shares
Core Web Vitals optimization guide for Next.js and React apps
adminOct 18, 2026
Web Development

Core Web Vitals optimization guide for Next.js and React apps

0 views0 likes0 shares

Leave a Comment


0/2000

Comments

Frank

Frank

Shared this with my team.

Oct 17, 2026

Erin

Erin

Any chance of a follow-up on caching?

Oct 17, 2026

On this page

  • Key takeaways
  • First, find out what the host actually supports
  • Two deployment models
  • Option A: deploy a static export
  • Option B: deploy a Node.js application
  • Environment variables and secrets
  • Images, caching and Server Actions
  • Database, email and cron
  • Troubleshooting
  • When to move off shared hosting
  • Frequently asked questions
  • Sources and further reading
  • Related services

NHRepon


Md. Nur Hossain Repon expert in NextJS, React, React Native and Flutter. He is a full-stack web and mobile application developer with 5+ years of experience and a passion for building innovative and robust application. Also, he has a strong background in developing high-quality web and mobile applications using the latest technologies and frameworks.
Let's build something amazing together 🚀

Quick Links


  • About
  • Projects
  • Services
  • Contact
  • Posts
  • Products
  • Privacy Policy
  • Terms of Service
  • Tools
  • Smart Life Hubs
  • Neuro Quotes

Newsletter


We respect your privacy. Unsubscribe anytime.

Connect


© 2026 NHRepon. All rights reserved.