All Case Studies
Case Study — NextDeployLevel 3 · Engineered

NextDeploy: Zero-Downtime Next.js Deployments Without Containers or Terraform

Open-source Go CLI and Linux daemon that deploys Next.js apps to bare-metal VPS, AWS Lambda, or Cloudflare Workers from one YAML config.

Go (Golang)AWSServerlessCloudflare WorkersLinuxDockerNext.jsReactTypeScriptJavaScriptNode.jsCI/CDAutomated testingSecuritySystem designObservabilitySQLGit

Live: https://hersi.dev/nextdeploy · Code: https://github.com/aynaash/NextDeploy · Skills proven: Go (Golang), AWS, Serverless, Cloudflare Workers, Linux, Docker, Next.js, React, TypeScript, JavaScript, Node.js, CI/CD, Automated testing, Security, System design, Observability, SQL, Git

The story

Context. Teams running Next.js App Router in production typically choose between managed platforms with high bandwidth markups or maintaining custom Dockerfiles, reverse proxies, and Terraform stacks on raw servers. NextDeploy provides a compiled Go CLI and Linux host daemon that build, provision, and ship Next.js apps directly from one nextdeploy.yml file to a bare-metal Linux VPS, AWS serverless infrastructure, or Cloudflare Workers.

My role and constraints. I authored and maintain the full codebase—covering the local Go CLI (nextdeploy), the Linux host daemon (nextdeployd), the nextcompile edge bundle adapter, and the cloud provider adapters. The design constraint was keeping production VPS requirements minimal (just SSH, systemd, and Caddy—no Docker daemon or Python/Ansible needed on target hosts) while supporting standalone Next.js streaming, Server Actions, and static asset continuity across deployments.

Key decisions.

  1. Dual-binary CLI and host daemon over SSH + HMAC Unix socket: Instead of pushing complex shell scripts over SSH or requiring a container runtime on a small VPS, the local nextdeploy CLI builds the app locally, streams app.tar.gz over SSH, and invokes nextdeployd. The daemon authenticates commands over an HMAC-SHA256 Unix domain socket (/run/nextdeployd/nextdeployd.sock), validates releases on an isolated port with TCP and HTTP probes, validates Caddy config in a sandbox, and flips a POSIX current symlink atomically via os.Rename.
  2. Direct cloud SDK provisioning over Terraform or CDK: The AWS adapter provisions Lambda, S3, CloudFront, ACM, IAM, and SQS directly via aws-sdk-go-v2. For Cloudflare Workers, a custom plan/apply/destroy engine reconciles Workers, R2, D1 migrations, KV, Hyperdrive, Queues, Vectorize, AI Gateway, and DNS while syncing encrypted AES-256-GCM state to R2 with S3 If-Match/If-None-Match optimistic locking.
  3. In-process esbuild + custom edge runtime (nextcompile): Rather than shelling out to separate wrappers, nextcompile compiles .next/standalone outputs into V8 isolate bundles supporting React Server Components Flight SSR (ssr.mjs), Server Actions (actions.mjs), edge rate limiting and CIDR protection (guard.mjs), and SSRF-checked image handling (image.mjs).
Local CLI (nextdeploy)          Target Infrastructure
──────────────────────          ─────────────────────────────────────────
nextdeploy ship                 VPS:  nextdeployd (HMAC socket)
  ├─ build standalone                 ├─ Extract -> releases/<ts>-<sha>
  ├─ package app.tar.gz               ├─ Isolated systemd unit + 0600 env
  ├─ verify metadata.json             ├─ TCP + HTTP health probe
  └─ upload / invoke target ──┬──>    ├─ Caddy sandbox validate + reload
                              │       └─ os.Rename -> current + shared_static/
                              │
                              └──> Edge: nextcompile -> R2/S3 static sync
                                      └─ V8 Worker / ARM64 Lambda + D1/SQS

What went wrong. Early deployments broke active browser tabs whenever a new build shipped because client bundles still requested hashed JavaScript chunks from the previous release. Separately, compiling Next.js builds on small 1GB RAM servers caused out-of-memory failures. Moving compilation onto the developer machine or CI runner, adding persistent shared static chunk pooling (shared_static/ on VPS and SHA-256 versioned asset prefixes on R2/S3), and rejecting cutover until dual-stage TCP + HTTP health probes pass resolved both failure modes.

Result. Shipped 37 tagged releases up to v0.20.1 supporting 24 CLI commands across VPS, AWS, and Cloudflare targets, verified by 110 automated test files and 6 GitHub Actions CI workflows (gosec, govulncheck, unit tests, Node --test runtime checks, and Next.js canary matrix testing).

The evidence

  • Architecture overview and command guides live at hersi.dev/nextdeploy
  • Public source repository and 37 tagged releases at github.com/aynaash/NextDeploy
  • Automated verification across 110 test files (Go unit tests, Node runtime tests, Vitest canary checks)
  • 6 GitHub Actions CI workflows covering linting, GoReleaser packaging, gosec, govulncheck, and Next.js canary compatibility
  • What I'd do next: publish structured OpenTelemetry trace exports for deployment stages and expand real-world deployment benchmarks across targets