CLI Reference
@nextgin/adapter ships the nextgin CLI for scaffolding, local development, multi-target builds, and single-VPS deployments.
nextgin init
Scaffolds a production-ready Next.js App Router + pure-Go 3-layer application (internal/{domain,store,service,httpapi}) with httptest tests, typed lib/api.ts, and a project AGENTS.md.
npx @nextgin/adapter init my-app
npx @nextgin/adapter init my-app --layout split --module github.com/acme/my-app
| Flag | Default | Description |
|---|---|---|
[dir] | . | Target directory to scaffold into |
--layout | selfhost | selfhost (single repo) or split (web/ + backend/ directories) |
--name | directory name | Package name written to package.json |
--module | example.com/<name> | Go module path written to go.mod |
--force | false | Allow scaffolding into a non-empty directory |
nextgin dev
Starts the Next.js development server (Turbopack HMR) and runs go run . in dev proxy mode so all /api/* and /_nextgin/cron/* routes are handled by Go while frontend edits hot-reload immediately.
npx nextgin dev
| Environment Variable | Default | Description |
|---|---|---|
PORT | 8080 | Public Go front-door listen port |
NEXT_PORT | 3001 | Internal Next.js dev server port |
NEXTGIN_INTERNAL_SECRET | unset | Shared secret for SSR → Go loopback calls |
nextgin build
Runs next build, emits .nextgin/manifest.json (static files, prerendered HTML routes, worker routes), copies the standalone Next.js server, and compiles the Go binary — or generates split-target artifacts (web/vercel.json, backend/Dockerfile).
# Self-hosted single binary + standalone worker
nextgin build
# Split mode: Next.js on Vercel + pure-Go container backend
nextgin build \
--web-target vercel \
--backend-target container \
--backend-url https://api.example.com
| Flag | Default | Description |
|---|---|---|
--web-target | selfhost | selfhost or vercel |
--backend-target | selfhost | selfhost or container |
--backend-url | — | Public HTTPS origin of the Go backend in split mode |
nextgin deploy
Builds and deploys a self-hosted nextgin app to any SSH-accessible Linux VPS with Docker, automatic Caddy HTTPS, optional PostgreSQL, and optional Redis.
nextgin deploy \
--host [email protected] \
--domain app.example.com \
--postgres \
--redis
| Flag | Description |
|---|---|
--host | SSH target (user@ip-or-hostname) |
--domain | Public domain for automatic Caddy TLS certificates |
--postgres | Provision a managed PostgreSQL container + DATABASE_URL |
--redis | Provision a Redis container + REDIS_URL for CronLocker |
--env-file | Local .env file synced securely to the server |