Skip to main content
This guide walks you through deploying a Next.js application on DCDeploy, including setup, build configuration, routing, and best practices.

Quick Start: Hello World

You can try deploying a minimal Next.js app to test the workflow.
  1. Create a new Next.js app:
  2. Replace the default page (app/page.tsx for App Router or pages/index.js for Pages Router) with:
  1. Start locally to verify:
  1. Commit and push to GitHub/Git provider.
  2. Deploy on DCDeploy using the steps in the guide below.

Overview

Next.js is a React framework that supports both static and server-rendered applications.
On DCDeploy, you can deploy Next.js using:
  • Node.js server mode (next start) for server-side rendering (SSR), API routes, etc.
  • Docker-based deployment for custom control.
  • Static export for static sites (no server-side features).

When to Use Each Mode


Prerequisites

  • Next.js project with either App Router or Pages Router.
  • package.json scripts:
  • If using Docker, a Dockerfile in your project root.
  • GitHub (or other Git) repository to push your project.

Step-by-Step Guide

  1. Prepare Your Next.js App
  • Choose router type (App Router or Pages Router).
  • Ensure dependencies are in package.json.
  • If using image optimization (next/image), ensure relevant libs like sharp may be installed.
  1. Add Dockerfile (optional but recommended for control)
Example Dockerfile:
If using static export (no server), you may build and serve static with a lightweight server or from static hosting.
  1. Push Code to Git
  • Initialize Git, commit all files, push to your git provider (GitHub, etc.).
  • Include .dockerignore to speed up builds when using Docker.
  1. Deploy on DCDeploy
  • In DCDeploy dashboard โ†’ Deploy tab in your target environment.
  • Create a new service โ†’ select Docker Registry / Build from Code.
  • Provide image or repo + branch.
  • Set port to 3000 (common for Next.js) and ensure app listens on 0.0.0.0.
  • Select protocol (http / https) and region(s).
  • Choose machine type (CPU, RAM) especially if SSR or many API routes.
  • Configure environment variables (NEXT_PUBLIC_*, database URLs, etc.).
  • Set minScale / maxScale. If your app is dormant at times, you can allow scaleโ€toโ€zero if enabled.
  • Deploy and monitor build + deploy logs.
Examples Node.js Server Example

Static Export Example

If using static export:
  • Run next export or configure Next.js to export static.
  • Serve from static hosting or minimal server.
  • Dockerfile might look like:

Best Practices

  • Use internal networking for connecting your Next.js app to databases / APIs within DCDeploy instead of making those publicly exposed.
  • Enable SSL / custom domain for production.
  • Monitor resource usage (CPU, memory), especially if using SSR or Server Components.
  • Use caching / ISR (Incremental Static Regeneration) wisely for performance.
  • Optimize image sizes and bundle sizes.

Troubleshooting