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:
Built-in Next.js server (recommended) β use
next build+next startwithout a custom server.Static export β generate a fully static site, ideal for sites without SSR or API Routes.
π Requirements
π§± 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:
Node.jsπ§Ή 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:
π¦ package.json β recommended scripts
Inside your package.json, make sure the main Next.js scripts are defined. A basic example:
π¦ TypeScript requirement (important)
If your project uses TypeScript, make sure it is installed under dependencies instead of devDependencies.
Some deployment environments only install production dependencies, which can cause build failures if TypeScript is missing.
β Correct example
β Incorrect example
π« Do not use the dist folder
By default, Next.js outputs build files into the .next directory. Keep that default and do not change distDir to dist.
π§© Deployment options
π 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:
Using in components:
ποΈ Recommended final project structure
A typical Next.js project structure for Discloud might look like:
π 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