Reference

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
FlagDefaultDescription
[dir].Target directory to scaffold into
--layoutselfhostselfhost (single repo) or split (web/ + backend/ directories)
--namedirectory namePackage name written to package.json
--moduleexample.com/<name>Go module path written to go.mod
--forcefalseAllow 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 VariableDefaultDescription
PORT8080Public Go front-door listen port
NEXT_PORT3001Internal Next.js dev server port
NEXTGIN_INTERNAL_SECRETunsetShared 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
FlagDefaultDescription
--web-targetselfhostselfhost or vercel
--backend-targetselfhostselfhost 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
FlagDescription
--hostSSH target (user@ip-or-hostname)
--domainPublic domain for automatic Caddy TLS certificates
--postgresProvision a managed PostgreSQL container + DATABASE_URL
--redisProvision a Redis container + REDIS_URL for CronLocker
--env-fileLocal .env file synced securely to the server