02. Client SDK/CLI Toolbelt

Enterprise CLI (npx nexus)

The CLI manages offline content synchronization, schema validation, TypeScript generation, and edge deployments through a Git-like workflow.

GIT-LIKE WORKFLOW
Diff & Push
Atomic Upstream Synchronizations

Track local schema modifications against the remote database with colorized diffs and conflict guards.

npx nexus diff · npx nexus push

CLI Command Catalog

WIZARD

npx nexus init

Scans project, creates .env.local, injects /sw.js, and auto-generates the Next.js revalidation route.

SYNC

npx nexus pull

Downloads production schemas and compiles offline .nx encrypted binaries.

CHANGESET

npx nexus diff

Shows pending changes (Added, Removed, Modified) between your local sandbox and upstream.

DEPLOY

npx nexus push

Validates against schema and executes an atomic push transaction to production.

npx nexus init

Runs the interactive initialization wizard:

  1. Detects your framework (Next.js App Router, Vite, Astro, SvelteKit).
  2. Validates Project ID & API Key against the Control Plane.
  3. Writes credentials to .env.local and updates .gitignore.
  4. Injects the Next.js revalidation route (app/api/revalidate/route.ts).
  5. Injects the PWA WebPush service worker (public/sw.js).
  6. Provisions dependencies (@nexushub/client, @opennextjs/cloudflare).

npx nexus pull

Downloads remote content and creates an encrypted upstream baseline (origin.nx):

1$ npx nexus pull
2 Connected to GN-Apex Edge API
3 Pulled 4 pages
4 Pulled 2 collections (blog_posts, products)
5 Compiled .nexus/origin.nx upstream baseline
6 Content synchronized successfully!

npx nexus diff

Compares your local .nexus/local/*.nx binaries against origin.nx:

1$ npx nexus diff
2Pending Changeset:
3 + [Added] blog_posts[2]: {"title": "Announcing v2.0", "slug": "v2"}
4 ~ [Modified] pages.home.hero_title: -"Old Headline" +"The Sovereign Platform"
5 - [Removed] pages.about.deprecated_field
6 
7Total changes: 3 (use 'npx nexus push' to publish)

npx nexus push

Validates your local data against the schema and pushes it live. Includes an upstream conflict-checking guard to prevent overwriting coworker changes made in the dashboard:

Conflict Resolution
If someone edited content in the dashboard after your last npx nexus pull, the push will abort with a conflict warning. Run npx nexus pull to re-sync or append --force to overwrite.

npx nexus types

Auto-generates strict TypeScript definitions from your CMS schema:

1$ npx nexus types --output types/nexus.d.ts
2 Schema loaded (4 pages, 2 collections)
3 Generated types/nexus.d.ts (184 lines)
4 Augmented @nexushub/client ContentEngine

npx nexus deploy

Compiles your Next.js application and deploys it directly to Cloudflare Pages:

  1. Requests an ephemeral 15-minute scoped deployment token from the Control Plane.
  2. Provisions a Cloudflare D1 tag cache database ([project]-tag-cache).
  3. Provisions a Cloudflare R2 cache bucket ([project]-cache-r2).
  4. Builds standalone output using opennextjs-cloudflare.
  5. Transfers assets to Cloudflare and binds your custom subdomain.

npx nexus doctor

Runs a diagnostic health check on your local environment (Node version, lockfile integrity, API connectivity, and package installation).