Next.js on CloudMagnus

Next.js with React installed and a placeholder app/page.tsx. Build locally, deploy via SFTP.

What our scaffold installs

  • npm init -y in htdocs/
  • npm install next react react-dom
  • A minimal next.config.js with reactStrictMode: true
  • A placeholder app/page.tsx rendering "Next.js site ready."
  • An allocated port from the 3000-3999 pool
  • nginx vhost reverse-proxying to 127.0.0.1:<allocatedPort>

What you do next

  1. SSH in.
  2. Run npx next dev --port <allocatedPort> to confirm the placeholder responds.
  3. Replace the placeholder app with your real code. Build locally with next build; ship the source + .next/ output via SFTP, or run next build over SSH.
  4. Run npx next start --port <allocatedPort> as your production process.

The allocated port is shown on the site detail page; substitute it for <allocatedPort> in the commands above.

Build pipeline

CloudMagnus does NOT run next build for you on deploy. You have two options:

  • Build locally / in CI, ship artifacts. Run next build on your laptop or in GitHub Actions. SFTP up your project including .next/. Run next start on the server.
  • Build on the server. SSH in, npm install, next build. Slower and uses server CPU; sometimes simpler.

Neither is automatic. We don't have CI integration today.

Process management

Same story as the generic Node guide: you keep next start running. Use pm2 (npm install pm2 && ./node_modules/.bin/pm2 start "next start --port <port>") or nohup or systemd user units.

App Router vs Pages Router

The placeholder uses the App Router (app/page.tsx). If you're using the Pages Router, replace the app/ directory with pages/ and adjust accordingly. Either is fine; nothing in our hosting cares.

Image optimization

Next.js's built-in next/image works with the default loader. The optimization runs on your Node process, not on a CDN. For high-traffic image-heavy sites, consider routing through Cloudflare's image resizing or an external image CDN.

Common Next.js issues

"Module not found" after deploy

npm install wasn't run on the server. SSH in and run it.

"Cannot find module 'next/dist/build'"

You uploaded source without node_modules/ AND haven't run install on the server. Either ship node_modules/ too, or run install over SSH.

SSR data fetching slow

Each request hits your server-side fetch calls. If those are slow, your pages are slow. CloudMagnus doesn't add caching in front of SSR; consider Cloudflare for cache-control or use Next's built-in revalidate options.

Static pages serve stale content

Next.js's static cache lives in .next/. If you replaced the build output, restart next start so it picks up the new bundle.

What CloudMagnus doesn't do for Next.js

  • Build your app on deploy.
  • Manage your next start process.
  • Provide an edge cache (use Cloudflare in front).
  • Run image optimization off-node (it runs on your Node process).