Next.js
On this page
Deploy a Next.js app behind Caddy with automatic HTTPS. Each deploy builds your app and restarts next start as a managed daemon.
Required services
On your server's Services tab, install Caddy and Node.js (24 by default). Add pnpm if your project uses it.
Create the site
- Open your server's Sites tab, click New site, and choose Next.js.
- Follow the App → Code → Domain → Run steps: pick your repository and branch, enter your domain (or Free domain), and review the Run step.
- On Run, Run the app as a daemon is enabled by default (
npm run start -- -p <port>), and Crabsmith adds its restart command to your deploy script automatically. - If your build needs
NEXT_PUBLIC_*or other build-time variables in.env.productionbefore the first build, uncheck Deploy after creating—otherwise leave it checked—and click Create site.
The default deploy script builds your app and restarts the daemon (commit package-lock.json so npm ci works reliably):
npm ci
npm run build
sudo systemctl try-restart crabsmith-daemon-<id>Using pnpm? Update Settings → Deployment to pnpm install --frozen-lockfile && pnpm run build (keeping the restart line), and update the daemon command under Processes to pnpm run start -- -p <port>.
Environment variables and deploying
If you deferred the first deploy, open the site's Environment tab (.env.production), add your build-time and runtime variables, click Save, and then click Deploy now.
Verify
Open your site in a browser. Check the running daemon and its logs anytime under Processes. (If you turned off Run the app as a daemon during setup, create a daemon there with npm run start -- -p <your-site-port> and paste its restart line into Settings → Deployment.)