Deploy a Next.js project
First determine whether the project requires a continuously running Node.js server. The answer depends on the Next.js version, router, server features and project configuration.
Option A: static export
When the site does not use SSR, API routes, Server Actions or other server features, a static export is simplest. Configure export mode according to the project's Next.js version and run:
npm ci
npm run buildUpload the resulting static directory, commonly out, to public_html. It then needs neither Node.js Selector nor NGINX Unit.
Option B: SSR or server features
- Verify the required Node.js version in
package.jsonand project documentation. - Upload the project outside
public_htmland install cleanly on the server. - Set production environment variables before building.
- Run
npm run buildand fix every error. - Select the runtime actually offered by the account: CloudLinux Selector or NGINX Unit.
- Configure the startup file for the project output and runtime. Do not invent a generic
app.jswithout verifying compatibility. - Start or restart the app and test HTML, static assets, images, APIs and authentication.
Domain or subpath
A dedicated domain or subdomain with the root path / is recommended. For /app/, configure basePath and, when required, assetPrefix; otherwise scripts, CSS and images can fail.
Update procedure
- Back up the project and database.
- Upload changes and run
npm ciin the correct environment. - Create a new production build.
- Restart the application through the panel.
- Verify key functions and review the log.