← Back to Blog
May 15, 20256 min read

Deploying Next.js to cPanel Without the Headaches

DeploymentcPanelNext.jsHosting

cPanel doesn't support Node.js server-side rendering, but that doesn't mean you can't deploy Next.js apps. Use static export to generate a fully static site that works perfectly on shared hosting.

Step 1: Configure Static Export

In your next.config.js, enable static export:

// next.config.js
module.exports = {
  output: 'export',
  images: {
    unoptimized: true
  },
  trailingSlash: true
}

Step 2: Build and Export

npm run build

This creates an out folder with all static files.

Step 3: Create ZIP and Upload

Zip the entire out folder, then upload to cPanel's File Manager. Extract in your domain's public_html directory.

Common Issues and Solutions

404 Errors

Ensure trailingSlash: true is set. cPanel serves directories better than files.

Images Not Loading

Set images.unoptimized: true for static export. This disables Next.js server-side image optimisation, which requires a runtime server that cPanel shared hosting cannot provide. Your images will still load; they just won't benefit from automatic WebP conversion and resizing.

Environment Variables

For static exports, only NEXT_PUBLIC_* variables are embedded at build time. Server-side environment variables are not available at runtime on shared hosting. Move any sensitive logic to an external API if you need secrets securely.

Key Takeaways

  • Static export (output: 'export') converts your Next.js app into plain HTML, CSS, and JavaScript — no Node.js server needed at runtime.
  • Set trailingSlash: true and images.unoptimized: true before building to avoid the two most common cPanel deployment issues.
  • The out/ folder is self-contained — extract it into public_html and your site is live immediately.
  • Automate deployment with a simple shell script that runs npm run build, zips the output, and uploads via FTP to eliminate manual steps and reduce error risk.
  • DiggaByte templates include cPanel-compatible next.config.js presets, so you can deploy to shared hosting in minutes without configuration changes.

Ready to Ship Your SaaS?

Stop writing the same boilerplate code. Browse our production-ready SaaS templates — each includes authentication, Stripe billing, database setup, and deployment configs so you can launch in days instead of months.

Check out our straightforward pricing, see how we compare to ShipFast and MakerKit, or read the documentation to understand exactly what you get. Questions? Learn about our team and mission, or catch up on our engineering blog.