Next.js
Practical guide to host Next.js applications on Discloud.
🧭 Introduction
This step-by-step guide shows how to prepare, configure, and deploy a Next.js application on Discloud.
There are two main approaches:
Option A (recommended) – use
next build+next startwithout a custom server (only the built-in Next.js server).Option B – use a custom server with Express, useful when you need extra routes, custom middleware, or specific integrations.
Additionally, we show an alternative with static export, ideal for purely static websites.
📋 Requirements
A Platinum plan or higher is required to host websites or APIs.
A subdomain must be created before deployment.
Port 8080 is mandatory – applications must listen on this port.
🧱 Local prerequisites
Before continuing, you will need:
Node.js installed on your machine.
A Next.js project created (e.g.
npx create-next-app).A Discloud account with a configured subdomain.
Optionally: Git, VSCode, and/or the Discloud CLI to make the workflow easier.
If you are not yet familiar with the local environment, check:
NodeJS🧹 Preparing project files
Before compressing your project into a .zip, create a .discloudignore file in the project root to exclude unnecessary files and folders from the upload:
node_modules/
dist/
.next/
.env
.env.local
.git
package-lock.json📦 package.json – recommended scripts
package.json – recommended scriptsInside your package.json, make sure the main Next.js scripts are defined. A basic example:
{
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start -p 8080",
"export": "next export"
}
}It is important that the start script uses port 8080 (next start -p 8080), as this is the default port required by Discloud for websites.
🔐 Environment variables
In Next.js, public environment variables must start with NEXT_PUBLIC_.
Define variables via the Discloud Dashboard, CLI, or API.
Everything that starts with
NEXT_PUBLIC_is embedded into the bundle during the build.
Example:
NEXT_PUBLIC_API_URL=https://my-backend.discloud.app
API_SECRET_TOKEN=do-not-put-in-frontendUsing in components:
const apiUrl = process.env.NEXT_PUBLIC_API_URL;🗂️ Recommended final project structure
A typical Next.js project structure for Discloud might look like:
my-next-app/
├─ discloud.config
├─ .discloudignore
├─ package.json
├─ next.config.js
├─ server.js # optional (only in Option B)
├─ public/
└─ app/ or pages/
├─ page.js
└─ api/
└─ hello.js🚀 Deploying to Discloud
You can deploy your Next.js app using any of the supported methods.
DashboardDiscord BotVisual Studio CodeCLI🛠️ Troubleshooting (common errors)
App does not open / wrong port
Check if Next is using port 8080 (next start -p 8080 or PORT=8080).
Plan / permission error
Confirm that your account has the correct plan for websites/APIs.
Subdomain not configured
Make sure you followed the subdomain guide before deploying.
Build errors
Run locally:
npm run buildand fix any errors before uploading.Check that all dependencies are listed in
package.json.
Errors when starting (START)
Verify that the
startscript is correct.Follow the Discloud logs to see the exact error message.
Last updated